Reputation: 764
I have a controller I made called test
and going to website.com/test
works just fine. How can I make that same controller respond if I try to go to website.com/test.html
?
Upvotes: 1
Views: 78
Reputation: 22242
RouteConfig.cs
is the place to look at.
Solution 1: IgnoreRoute
In your RouteConfig.cs
, under RegisterRoutes(RouteCollection routes)
:
routes.IgnoreRoute("*.html");
Please make sure your IgnoreRoute
statement is place ahead of all other MapRoute
statement.
Solution 2: MapRoute
routes.MapRoute(
name: "HtmlUrl",
url: "{action}.html",
defaults: new { controller = "Home"}
);
Upvotes: 1
Reputation: 11397
AttributeRouting for example can do that
Example :
[GET("test")]
[GET("test.html")]
public ActionResult test()
{
return view();
}
Upvotes: 1