I have a problem with the web service in asmx
that saves images and that I consume from an Android app:
This is the error it generates:
System.NullReferenceException: Object reference not set as instance of an object. in WebServicesLogistica.ServicesLogistica.CreateRequest () in c: \ Users \ SUPPORT \ Desktop \ PROJECT LOGISTICS \ WebSistemaLogisticoR \ WebServicesLogistica \ WebServi cesLogistica \ Service sLogistica.asmx.cs: l line 303
Service code:
[WebMethod]
public void SaveImage()
{
try
{
if (!System.IO.Directory.Exists(HttpContext.Current.Server.MapPath("~/Upload")))
{
System.IO.Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~/Upload/"));
}
string path = HttpContext.Current.Server.MapPath("~/Upload/").ToString();
var Request = HttpContext.Current.Request;
if (Request.Files.Count > 0)
{
var file = Request.Files[0];
file.SaveAs(path + file.FileName);
}
}
catch(Exception ex){
throw ex;
}
}
Command in multipart/form-data