Could someone explain how this ignore route works?

359 views Asked by At

So I added an ASMX web service to my MVC4 but when I tried to access it I got a "The Resource could not be found" error. After searching I found the answer here.

In short, I had to add the following IgnoreRoute to my RouteConfig file.

routes.IgnoreRoute("{*x}", new { x = @".*\.asmx(/.*)?" }); 

I understand the MapRoute function in MVC fairly well, however the IgnoreRoute, not so much. I understand that it's targeting the .asmx postfix but I'm not sure on the how's and why's of this quick fix.

How does this IgnoreRoute work, and exactly why does it make my MVC app magically understand how to find and execute my web service? BTW, My only mapped route, currently, is the default, but is there another/better way of solving this issue using MapRoute or another fix?

1

There are 1 answers

2
Aman B On BEST ANSWER

ignore route indicates that routing should ignore these requests and ASP.NET processing of these requests will occur. http://haacked.com/archive/2008/07/14/make-routing-ignore-requests-for-a-file-extension.aspx/