Reputation: 3545
I have the following route in my MVC applicaiton:
routes.MapRoute(
name: "Default",
url: "api/{server}/{port}/{route}",
defaults: new {
controller = "Home",
action = "Index",
server = UrlParameter.Optional,
port = UrlParameter.Optional,
route = UrlParameter.Optional }
);
This route gets hit when the URL is http://localhost:80/api/myserver.mydomain.net/8080/mypage
but when I change the URL to http://localhost:80/api/myserver.mydomain.svc/8080/mypage
the route suddenly does not get hit. Any idea why simply changing an argument in my route from '.net' to '.svc' would stop working?
Upvotes: 0
Views: 50
Reputation: 3545
I found the answer to my question here. All I had to do was remove the .svc build provider from my site:
<system.web>
<compilation debug="true" targetFramework="4.0">
<buildProviders>
<remove extension=".svc"/>
</buildProviders>
...
Upvotes: 2
Reputation: 2316
The .svc
is a path extension for WCF end points, so IIS will be processing this via a different mechanism (ISAPI module/handler) not through the MVC/WebAPI route engine.
Try adding the following to your web.config
, it will force IIS to run the routing engine with each request.
<configuration>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
.....
Note: this may add an unnecessary overhead to your page requests.
Another option might be to remove the module itself, but this will affect any WCF endpoints you may be running.
<configuration>
<system.webServer>
<modules>
<remove name="ServiceModel-4.0" />
.....
Upvotes: 1