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
I used this and it worked:
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();
}
}
Apparently this works too:
routes.Add(new Route("favicon.ico", new StopRoutingHandler()));
I just needed to close Firefox, clear my history and try again.