久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

ASP.NET 路由:標記之間的文字子段,并使用文字子

ASP.NET routing: Literal sub-segment between tokens, and route values with a character from the literal sub-segment(ASP.NET 路由:標記之間的文字子段,并使用文字子段中的字符路由值) - IT屋-程序員軟件開發技術分
本文介紹了ASP.NET 路由:標記之間的文字子段,并使用文字子段中的字符路由值的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我問的原因是因為 IIS 保護某些 ASP.NET 文件夾,如 Bin、App_Data、App_Code 等.即使 URL 未映射到實際的文件系統文件夾 IIS 拒絕路徑段等于的 URL到提到的名字之一.

The reason I'm asking is because IIS protects certain ASP.NET folders, like Bin, App_Data, App_Code, etc. Even if the URL does not map to an actual file system folder IIS rejects a URL with a path segment equal to one of the mentioned names.

這意味著我不能有這樣的路線:

This means I cannot have a route like this:

{controller}/{action}/{id}

... 其中 id 可以是任何字符串,例如

... where id can be any string e.g.

Catalog/Product/Bin

因此,我愿意更改路由,而不是禁用此安全措施,在 id 之前使用后綴,如下所示:

So, instead of disabling this security measure I'm willing to change the route, using a suffix before the id, like these:

{controller}/{action}_{id} // e.g. Catalog/Product_Bin
{controller}/{action}/_{id} // e.g. Catalog/Product/_Bin

但如果 id 包含新的分隔符,則這些路由將不起作用,在這種情況下為 _,例如

But these routes won't work if the id contains the new delimeter, _ in this case, e.g.

// These URL won't work (I get 404 response)
Catalog/Product_Bin_
Catalog/Product/_Bin_
Catalog/Product/__Bin

為什么?我不知道,對我來說似乎是一個錯誤.我怎樣才能使這些路由工作,其中 id 可以是任何字符串?

Why? I don't know, looks like a bug to me. How can I make these routes work, where id can be any string?

推薦答案

好的,我有一個明確的答案.是的,這是一個錯誤.但是,在這一點上,我很遺憾地說我們沒有計劃修復它,原因有兩個:

Ok, I have a definitive answer. Yes, this is a bug. However, at this point I regret to say we have no plans to fix it for a couple of reasons:

  • 這是一個重大變化,可能很難被注意到.
  • 有一個簡單的解決方法.

您可以做的是將 URL 更改為不包含下劃線:

What you can do is change the URL to not have the underscore:

{controller}/{action}/_{id}

然后添加一個路由約束,要求ID參數以下劃線字符開頭.

Then add a route constraint that requires that the ID parameter starts with an underscore character.

然后在您的操作方法中,您從 id 參數中刪除下劃線前綴.如果您愿意,您甚至可以編寫一個動作過濾器來為您執行此操作.很抱歉給您帶來不便.

Then within your action method you trim off the underscore prefix from the id parameter. You could even write an action filter to do this for you if you liked. Sorry for the inconvenience.

這篇關于ASP.NET 路由:標記之間的文字子段,并使用文字子段中的字符路由值的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

ASP.NET Core authenticating with Azure Active Directory and persisting custom Claims across requests(ASP.NET Core 使用 Azure Active Directory 進行身份驗證并跨請求保留自定義聲明)
ASP.NET Core 2.0 Web API Azure Ad v2 Token Authorization not working(ASP.NET Core 2.0 Web API Azure Ad v2 令牌授權不起作用)
ASP Core Azure Active Directory Login use roles(ASP Core Azure Active Directory 登錄使用角色)
How do I get Azure AD OAuth2 Access Token and Refresh token for Daemon or Server to C# ASP.NET Web API(如何獲取守護進程或服務器到 C# ASP.NET Web API 的 Azure AD OAuth2 訪問令牌和刷新令牌) - IT屋-程序員軟件開發技
.Net Core 2.0 - Get AAD access token to use with Microsoft Graph(.Net Core 2.0 - 獲取 AAD 訪問令牌以與 Microsoft Graph 一起使用)
Azure KeyVault Active Directory AcquireTokenAsync timeout when called asynchronously(異步調用時 Azure KeyVault Active Directory AcquireTokenAsync 超時)
主站蜘蛛池模板: 99亚洲 | 成人午夜视频在线观看 | 欧美国产在线一区 | 欧美一区二区三 | jlzzjlzz欧美大全 | 日本男人天堂 | 久久精品中文 | 在线免费毛片 | 精品欧美一区二区在线观看欧美熟 | 欧美精品第三页 | 色综合一区二区三区 | www国产精| 武道仙尊动漫在线观看 | 久久在线 | 手机看片169| 亚洲一区二区欧美 | 日韩视频在线免费观看 | av网站免费观看 | 国产激情视频在线观看 | 国产一区二区三区色淫影院 | 国产一区二区久久 | 免费观看日韩精品 | 一区二区在线 | 久久毛片| 国产福利在线小视频 | 国产精品国产精品国产专区不片 | 国产大毛片 | 日韩精品久久久 | 亚洲精品一级 | 亚洲免费三区 | 羞羞的视频免费观看 | av在线视| 一级黄色绿像片 | 伊人99| 久久一区二区三区免费 | 韩国av一区二区 | 一区二区三区免费在线观看 | 免费观看一级特黄欧美大片 | 精品国产一区二区三区久久久久久 | 日韩免费一二三区 | 影音先锋亚洲资源 |