[英]ASP.NET Web API Fails When Attribute Has Period - 404 Not Found
IIS 10.0,VS 2022,.NET 框架 4.7.2 Web API
我繼承了一個 web api 應用程序,有人告訴我它上次發布時 100% 有效(至少一年前,也許 2)。 但是,現在當屬性包含句點時我得到 404 未找到(在 IDE 中使用 IIS 和在服務器上發布到 IIS 時)。
我嘗試使用 2 種方法創建一個新的 web api 應用程序:
[HttpPost]
[Route("BatchData/ProcessResponseByString/{requestId}")]
public HttpResponseMessage ProcessResponseByString(string requestId)
{
return new HttpResponseMessage()
{
Content = new StringContent($"String:{requestId}")
};
}
[HttpPost]
[Route("BatchData/ProcessResponseByDouble/{requestId:double}")]
public HttpResponseMessage ProcessResponse(double requestId)
{
return new HttpResponseMessage()
{
Content = new StringContent($"Double:{requestId}")
};
}
這些網址有效: https://localhost:44352/BatchData/ProcessResponseByString/12345 https://localhost:44352/BatchData/ProcessResponseByDouble/12345
這些 url 失敗並顯示 404 未找到:https://localhost:44352/BatchData/ProcessResponseByString/12345.67 https://localhost:44352/BatchData/ProcessResponseByDouble/12345.67
也許 IIS 升級改變了 IIS 中路由的解析方式?
關於如何解決這個問題的任何想法?
謝謝。
@Paritosh 發布了鏈接( 為什么我的 Web API 方法沒有調用雙參數? )並建議 / 解決方法(感謝鏈接),但對我有用的答案是在 / 建議之后 - 更新 webconfig
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.