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

ASP.NET 路由:標(biāo)記之間的文字子段,并使用文字子

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

問題描述

限時送ChatGPT賬號..

我問的原因是因?yàn)?IIS 保護(hù)某些 ASP.NET 文件夾,如 Bin、App_Data、App_Code 等.即使 URL 未映射到實(shí)際的文件系統(tǒng)文件夾 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?

推薦答案

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

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參數(shù)以下劃線字符開頭.

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

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

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.

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

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

相關(guān)文檔推薦

ASP.NET Core authenticating with Azure Active Directory and persisting custom Claims across requests(ASP.NET Core 使用 Azure Active Directory 進(jìn)行身份驗(yàn)證并跨請求保留自定義聲明)
ASP.NET Core 2.0 Web API Azure Ad v2 Token Authorization not working(ASP.NET Core 2.0 Web API Azure Ad v2 令牌授權(quán)不起作用)
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(如何獲取守護(hù)進(jìn)程或服務(wù)器到 C# ASP.NET Web API 的 Azure AD OAuth2 訪問令牌和刷新令牌) - IT屋-程序員軟件開發(fā)技
.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(異步調(diào)用時 Azure KeyVault Active Directory AcquireTokenAsync 超時)
主站蜘蛛池模板: 亚洲国产小视频 | 午夜免费视频 | 在线欧美视频 | 日韩欧美大片在线观看 | 亚洲国产精品久久久久 | 成人三级视频在线观看 | 91精品国产麻豆 | 日韩伦理电影免费在线观看 | 黑人精品欧美一区二区蜜桃 | 香蕉一区二区 | 一级欧美黄色片 | 久久国内精品 | 午夜天堂精品久久久久 | 波多野结衣av中文字幕 | 亚洲在线高清 | 国产在线一区二区三区 | 天天在线操 | 国产亚洲一区二区精品 | 韩国精品在线观看 | 99精品久久久久 | 老牛嫩草一区二区三区av | 毛片一区二区三区 | 三级视频在线观看电影 | 欧美精品网站 | 天天干夜夜操 | 99re视频在线观看 | 精品久久久久久国产 | 精品久久久久久久久久久久 | 超碰地址 | 国产精品一区二 | 国产视频一二三区 | av黄色国产 | 91国内视频在线 | 一区二区三区四区视频 | 中文字幕一区二区三区四区五区 | 久久久精品一区二区 | 亚洲男人网| 国产97久久| 日韩三级 | 国产精品久久久久婷婷二区次 | 亚洲欧美在线一区 |