9
Answers

Why HttpPost isn't working in WebApi

I am making an ajax request from the clientside to my web service built in web api.
Here is the client side code :
 
$.ajax({
url: "http://localhost:1583/api/storage/processing/v1/preview/test.docx",
type: "POST",
contentType: "application/json; charset=utf-8",
dataType: "json",
cache: false,
responseType: "json",
beforeSend: onProgress,
success: GenerateHtml,
complete: onComplete,
error: onFail
});
 
Here is the controller's code:
[HttpPost]
[Route(WebApiConfig.RootApiUri + "/v1/preview/{docid}")]
public async Task<List<HtmlViewInformationV1Dto>> Preview(string docid)
{
    ///...ommitted the code..///
}
 HttpPost isn't working, however if change it to HttpGet it works.
 Any help on this would be greatly appreciated. Thanks.
 
Answers (9)