1

In my application, Both mvc and web form is present.

But when I open any .aspx page then in Application_Error error is thrown.

The controller for path '/WebResource.axd' was not found or does not implement IController.

The controller for path '/ScriptResource.axd' was not found or does not implement IController.

I tried all these method, but none of them is working.

  • Added at top in RegisterRoutes method.

    routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.IgnoreRoute("{*allaspx}", new { allaspx = @".*\.aspx(/.*)?" });

  • Create a FileTypeConstraint class to check file ext.

.

public class FileTypeConstraint : IRouteConstraint
    {
        private readonly string[] MatchingFileTypes;

        public FileTypeConstraint(string matchingFileType)
        {
            MatchingFileTypes = new[] { matchingFileType };
        }

        public FileTypeConstraint(string[] matchingFileTypes)
        {
            MatchingFileTypes = matchingFileTypes;
        }

        public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
        {
            if (values["url"] != null)
            {
                string path = values["url"].ToString();
                return MatchingFileTypes.Any(x => path.ToLower().EndsWith(x, StringComparison.CurrentCultureIgnoreCase));
            }
            else
            {
                return false;
            }
        }

And added this line at top and bottom both

 routes.MapRoute(
     "Defaultaxd",
      "{*url}",
       new { controller = "Home", action = "Index", id = UrlParameter.Optional },
        new { myCustomConstraint = new FileTypeConstraint(new[] { "axd" }) }
          );

Tried all these links.

HttpHandlers with ASP.NET MVC

ASP.NET MVC routing issue?

Using URL Routing for Web Forms and StopRoutingHandler for Favicon

Community
  • 1
  • 1
Amit Kumar
  • 5,888
  • 11
  • 47
  • 85
  • Check out some of the alternative answers on http://stackoverflow.com/questions/2109841/im-getting-a-does-not-implement-icontroller-error-on-images-and-robots-txt-in maybe those work – Shogunivar Apr 05 '17 at 07:14
  • @Shogunivar: already checked that link too. None of those method works. – Amit Kumar Apr 05 '17 at 07:17

0 Answers0