API Code:
[HttpPost]
[Route("Upload")]
public HttpResponseMessage Upload([FromBody]FileUpload objFileUpl)
{
try
{
var AttachmentInfoResult = PLMRepository.PlmFileUpload(objFileUpl);
return Request.CreateResponse<attachmentinfo>(HttpStatusCode.OK, AttachmentInfoResult);
}
catch (Exception ex)
{
WriteToLog(ex);
return Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message.Replace("ERROR: ", ""));
}
}
MVC controller:
[HttpPost]
public JsonResult FilesUpload()
{
try
{
return this.Json(objAtList, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
WriteToLog(ex, "UploadController");
throw;
}
Here in above exception in api should be thrown to mvc controller from where the api was triggered
What I have tried:
i tried throw in web api catch section