I have an exception in project: The controller for path '/Content/Images/CustomFavicon.ico' was not found or does not implement IController.
I have found answer here: I'm getting a "Does not implement IController" error on images and robots.txt in MVC2
which gives me description of my problem and solution for it.
However I am weak on regular expressions, so have the same problem. How can i modify this expression to math both paths of icon expression for example below:
(/.*)?CustomFavicon.ico?(/.*)
if my html link file look
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="ctl00_Head1">
<link rel="shortcut icon" HREF="/Content/Images/CustomFavicon.ico">
<link rel="icon" href="/Content/Images/CustomFavicon.ico" type="image/x-icon"><title>
Home Page
</title></head>
<body>
acodring to my test (see below), it finds only one match which also contains html I don't want:
see here my test: http://regexr.com?2tl开发者_高级运维4a
This is going to be used in my Global.aspx file:
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{resource}.aspx/{*pathInfo}");
//ignore route for ico files
routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?CustomFavicon.ico(/.*)?" });
From your regex I am not sure what you want to match. I modified it a bit so that the two path are matched.
(?:\/.*?)CustomFavicon.ico
See here your modified example
If you want to have this in a capturing group, then put brackets around it, like:
((?:\/.*?)CustomFavicon.ico)
精彩评论