0

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?2tl4a

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(/.*)?" });
Community
  • 1
  • 1
cpoDesign
  • 8,953
  • 13
  • 62
  • 106

1 Answers1

0

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)
stema
  • 90,351
  • 20
  • 107
  • 135
  • i need to add exception to ignore routes for ico files into my global.aspx, see my original post – cpoDesign Apr 28 '11 at 13:23
  • @Pavel, I have not realy an idea what the Global.aspx file is good for. My regex is matching the two pathes to the *.ico files. If you need something else to match or not to match, then please specify it that I can improve my regex. – stema Apr 28 '11 at 13:44
  • hi, i will be able to do so in the tuesday, still it match the regex, thank you for that :) – cpoDesign Apr 28 '11 at 18:07