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

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

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

問題描述

限時送ChatGPT賬號..

我有一個需要添加 Favicon.ico 的網(wǎng)站.該站點是使用帶有路由的 ASP.NET 3.5 Web 窗體編寫的.問題是 Favicon 鏈接總是返回一個找不到頁面的錯誤.這是因為路由不知道 Favicon.ico 的鏈接應(yīng)該去哪里,所以它返回 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)站圖標(biāo)添加 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()));

有人知道我應(yīng)該使用什么嗎?我嘗試過的 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> 標(biāo)簽內(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 應(yīng)用程序.

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 超時)
主站蜘蛛池模板: 欧美日韩在线一区二区 | 一区二区av | 夜夜久久 | 国产一级大片 | 国产在线高清 | 中文字幕一区二区三区四区 | 色五月激情五月 | 成人午夜免费视频 | 先锋av资源在线 | 日韩视频中文字幕 | 天天躁日日躁xxxxaaaa | 日韩精品一区二区三区视频播放 | 国产精品美女久久久久aⅴ国产馆 | 亚洲精品在线免费观看视频 | 亚洲首页| 一区二区免费视频 | 亚洲狠狠丁香婷婷综合久久久 | 亚洲国产成人精品久久 | 在线观看www视频 | 欧美一级在线观看 | 久久九九99 | 九九热在线精品视频 | 久久噜噜噜精品国产亚洲综合 | 久久一区二区视频 | 国产精品一区二区三区在线 | 免费观看www7722午夜电影 | 欧美久久久网站 | 人操人免费视频 | 国产欧美在线播放 | 午夜精| 91精品久久久 | 激情免费视频 | 成人无遮挡毛片免费看 | 嫩草影院黄| 国产九九av | 精品欧美乱码久久久久久 | 欧美福利精品 | 一级黄色片免费在线观看 | 九九久久精品 | 久久久久国产精品午夜一区 | 一区日韩 |