A first chance exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll when I try to upload a file to server.
$('#But_Upload').click(function () {
console.log("its working\n");
var ajaxRequest = $.ajax({
type: "POST",
url: "../HANDLERS/Handler1.ashx",
contentType: false,
processData: false,
data: $('#upload').get(0).files.toString(),
async: true,
success: function (xhr) {
console.log("done");
}
});
});
});
</script>
My server code in C# handler is
public void ProcessRequest(HttpContext context)
{
System.Diagnostics.Debug.Write(context.ToString());
try
{
HttpPostedFile httpPostedFile = context.Request.Files.Get(0);
var fileSavePath = HttpContext.Current.Server.MapPath("~/upl") + httpPostedFile.FileName;
httpPostedFile.SaveAs(fileSavePath);
}
catch(Exception E)
{ }
}
I am getting the exception exactly at httpPostedFile line,I have been fighting with this for donkey age ,pls help.