How to ignore route in asp.net forms url routing

后端 未结 4 423
梦谈多话
梦谈多话 2020-12-01 06:36

I am using the .NET 3.5 SP1 framework and I\'ve implemented URL routing in my application. I was getting javascript errors:

Error: ASP.NET Ajax client-side

相关标签:
4条回答
  • 2020-12-01 07:02

    An old question but in case it still helps anyone, this worked for me:

    routes.Ignore("{resource}.axd/{*pathInfo}");
    

    The "Ignore" method exists, whereas in standard ASP.NET the "IgnoreRoute" method appears not to (i.e., not using MVC). This will achieve the same result as Haacked's code, but is slightly cleaner ...

    0 讨论(0)
  • 2020-12-01 07:10

    I would just like to add that you also need to make sure the order of your IgnoreRoutes rule is in the the correct order otherwise your first route will be applied first and your IgnoreRoute will... well be ignored.

    0 讨论(0)
  • 2020-12-01 07:22

    MapRoute and IgnoreRoute are extension methods in System.Web.Mvc --- do you have that assembly referenced properly?

    0 讨论(0)
  • 2020-12-01 07:25

    You don't need to reference ASP.NET MVC. You can use the StopRoutingHandler which implements IRouteHandler like so:

    routes.Add(new Route("{resource}.axd/{*pathInfo}", new StopRoutingHandler()));
    

    This is part of .NET 3.5 SP1 and doesn't require MVC. The IgnoreRoutes method is a convenience extension method which is part of ASP.NET MVC.

    0 讨论(0)
提交回复
热议问题