Reputation: 4862
I've a angularJS application. I've created a controller/action that returns a rendered index.cshtml on any request. This is my only mvc4 controller. I use the webapi for all other behavior. The client-side should only handling the routes. Works well so far.
RouteExistingFiles = false;
routes.MapRoute(
name: "Default",
url: "{*url}",
defaults: new { controller = "Index", action = "Index" }
);
The problem is that this solution matches resources like "localhost/favicon.ico, localhost/template.html". Can i prevent or ignore all request like this ?
Upvotes: 4
Views: 1499
Reputation: 18873
You can try something like this, then routing module ignores requests for any .html and .ico files :-
routes.IgnoreRoute("{*allhtml}", new {allhtml=@".*\.html(/.*)?"});
routes.IgnoreRoute("{*favicon}", new {favicon=@"(.*/)?favicon.ico(/.*)?"})
Upvotes: 2
Reputation: 34992
You could use IgnoreRoute
so the routing module ignores requests for those resources, for example:
routes.IgnoreRoute("favicon.ico");
routes.IgnoreRoute("{templateName}.html");
These have to be added before your current Default
route.
Upvotes: 4