我一直在掙扎4個小時,我仍然沒有得到任何解決方案。我已經申請了一些修改,但仍然是我的職位和刪除API返回錯誤500web api得到工作,但後發佈和刪除不工作後發表在iis
GET JS
$.getJSON(API_URL + 'api/claim/search', params).done(function (data) {
myJsonObject = data;
d.resolve(data);
});
return d.promise();
API
[Route("api/claim/search")]
[System.Web.Http.AcceptVerbs("GET")]
[System.Web.Http.HttpGet]
public IEnumerable<ClaimInfo> Get([FromUri] ClaimSearch obj_ClaimSearch)
{
//my code
}
這GET方法的工作100%
POST js
$.ajax({
type: "POST",
data: JSON.stringify(p[0]),
url: API_URL + "api/claim/" + (editorPage === "resubmission" ? "saveresubmissionpatient": "savepatient"),
contentType: "application/json",
success: function (data) {
},
error: function() {
}
});
API
[Route("api/claim/savepatient")]
[System.Web.Http.AcceptVerbs("POST")]
[System.Web.Http.HttpPost]
public Guid SavePatient([FromBody]ClaimInfo claimInfo)
{
//my code
}
這裏是我的WebApi.Config.cs
public static void Register(HttpConfiguration config)
{
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
我已經在我的配置
<modules>
<remove name="WebDAVModule" />
<add type="DevExpress.Web.ASPxHttpHandlerModule, DevExpress.Web.v16.2, Version=16.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" name="ASPxHttpHandlerModule" />
</modules>
<handlers>
<remove name="WebDAV" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
?是在操作之前還是之後發生的錯誤? – Nkosi