我有一個在Azure中運行的ASP.NET 6 MVC應用程序。我有一個動作控制器像如何在Azure中允許URL編碼路徑段
[HttpDelete]
[Route("{image_url}")]
public async Task<IActionResult> RemoveImageUrl([FromRoute(Name = "image_url")] String imageUrlString)
然後我把它像
api/https%3A%2F%2Frepocreator.zoltu.io%2Fimages%2FZoltu-Logo-Full-Size.png"
此應用程序正常工作時的自我與Kestrel的託管,但只要我部署到Azure中,我得到500錯誤。我儘可能多地進行了調試,並且經過大量Google搜索後,似乎IIS正在試圖幫助URL解碼請求,然後再將其轉發給ASP.NET進行處理。這個問題,當然是,即使我能說服IIS來接受
<system.webServer>
<security>
<requestFiltering allowDoubleEscaping="true" />
</security>
</system.webServer>
<system.web>
<httpRuntime requestValidationMode="2.0" requestPathInvalidCharacters="" relaxedUrlToFileSystemMapping="true"/>
<pages validateRequest="false" />
</system.web>
請求它仍然解碼URL並傳遞到ASP.NET解碼URL不找到一個匹配的路由。
我該怎麼做才能告訴IIS停止嘗試在此處獲得幫助,並且只傳遞它獲取的任何URL,而不進行任何形式的預驗證或重寫。注意:這是一個Azure Web應用程序,所以我沒有直接訪問IIS設置。
米卡,我遇到了類似的問題......你有沒有想出一個令人滿意的解決方案? – err1100
我最終登陸的解決方案是停止使用IIS進行託管。我不記得我是否解決了這個具體的解決方案,但是總的來說,IIS最終比它更值得痛苦。我現在把我的所有東西都放到了Kestrel的Docker中,我的生活變得更加簡單了。 –
哈。好的謝謝。 – err1100