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

為 Web 表單使用 URL 路由,為 Favicon 使用 StopRout

Using URL Routing for Web Forms and StopRoutingHandler for Favicon(為 Web 表單使用 URL 路由,為 Favicon 使用 StopRoutingHandler)
本文介紹了為 Web 表單使用 URL 路由,為 Favicon 使用 StopRoutingHandler的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我有一個需要添加 Favicon.ico 的網(wǎng)站.該站點是使用帶有路由的 ASP.NET 3.5 Web 窗體編寫的.問題是 Favicon 鏈接總是返回一個找不到頁面的錯誤.這是因為路由不知道 Favicon.ico 的鏈接應該去哪里,所以它返回 Not Found 頁面.

I have a website where I need to add a Favicon.ico. The site is written using ASP.NET 3.5 Web Forms with Routing. The issue is that the Favicon link always returns a page not found error. This is because the Routing does not know where the link for Favicon.ico should go to so it returns the Not Found page.

我嘗試為網(wǎng)站圖標添加 StopRoutingHandler,但它們似乎都不起作用.以下是我迄今為止嘗試過的:

I have tried to add a StopRoutingHandler for the the favicon but none of them seem to work. Below are the ones I have tried so far:

routes.Add(new Route("MasterPages/{favicon}.ico", new StopRoutingHandler()));
routes.Add(new Route("{favicon}.ico", new StopRoutingHandler()));
routes.Add(new Route("favicon.ico", new StopRoutingHandler()));
routes.Add(new Route("favicon.ico/{*pathInfo}", new StopRoutingHandler()));

有人知道我應該使用什么嗎?我嘗試過的 favicon.ico 鏈接如下所示:

Does anyone know what I should be using? My favicon.ico links I have tried look like this:

<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link rel="icon" href="/favicon.ico" type="image/x-icon" />

它們在我的 <html><head> 標簽內(nèi).

And they are inside of my <html><head> tags.

另外,作為最后一點,我沒有使用 MVC,因為如果我可以使用它:

Also, as one final note, I am not using MVC because if I was I could use this:

routes.IgnoreRoute("{*favicon}", new {favicon=@"(.*/)?favicon.ico(/.*)?"});

很遺憾,IgnoreRoute 不適用于路由 Web 表單,因為它不是 MVC 應用程序.

Unfortunately, IgnoreRoute does not work for Routing Web Forms though because it is not an MVC application.

推薦答案

我用過,效果不錯:

routes.Add(new Route("favicon.ico", new StaticFileRouteHandler("~/favicon.ico")));

public class StaticFileRouteHandler : IRouteHandler
{
    public string VirtualPath { get; set; }
    public StaticFileRouteHandler(string virtualPath)
    {
        VirtualPath = virtualPath;
    }

    public System.Web.IHttpHandler GetHttpHandler(RequestContext requestContext)
    {
        HttpContext.Current.RewritePath(VirtualPath);
        return new DefaultHttpHandler();
    }
}

顯然這也有效:

routes.Add(new Route("favicon.ico", new StopRoutingHandler()));

我只需要關(guān)閉 Firefox,清除我的歷史記錄,然后重試.

I just needed to close Firefox, clear my history and try again.

這篇關(guān)于為 Web 表單使用 URL 路由,為 Favicon 使用 StopRoutingHandler的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 進行身份驗證并跨請求保留自定義聲明)
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(如何獲取守護進程或服務(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 超時)
主站蜘蛛池模板: 欧美一区二区视频 | 国产精品免费在线 | 国产欧美一区二区三区日本久久久 | 精品视频一区在线 | 一本大道久久a久久精二百 欧洲一区二区三区 | 特黄视频| 超碰av在线 | 欧美一级欧美三级在线观看 | 人人玩人人干 | 激情91| 91免费入口 | 美女黄视频网站 | 91亚洲精品久久久电影 | 国产综合在线视频 | 亚洲国产精品99久久久久久久久 | 国产日韩精品久久 | 中文字幕一区二区三区精彩视频 | av午夜电影 | 特黄色一级毛片 | 久久国产视频一区 | 国产sm主人调教女m视频 | av夜夜操| 日韩国产欧美 | 日韩视频中文字幕 | 日韩视频一级 | 黄a在线播放 | a a毛片 | 久久久久久国模大尺度人体 | 欧美国产一区二区 | 欧美xxxx做受欧美 | 男人的天堂在线视频 | 精品一区二区三区免费视频 | 中文字幕一区在线观看视频 | 91精品国产高清一区二区三区 | 好姑娘影视在线观看高清 | 免费视频99 | 蜜臀久久 | 国产福利视频网站 | 日韩图区| 日韩a | 91久久网站 |