ASP.NET MVC Routing: How to make my MVC URL's have .aspx extension?

tripilmessutt

New Member
I want an MVC app to have .aspx page URLs even though there will not be any physical aspx pages and I will be using the Razor view engine.1) Is it possible to define such a route?2) What would that route look like if I wanted a url such as, say, the one given below:\[code\]http://example.com/controller/action.aspx\[/code\]and optionally\[code\]http://example.com/controller/action.aspx/id\[/code\]and optionally\[code\]http://example.com/controller/action.aspx?queryParam1=value&queryParam2=value\[/code\] (and so on...)UPDATEI realize I want URL's like this:\[code\]http://example.com/controller/id.aspx\[/code\]In other words, I want no specific action to be specified. A default action will process all requests.ANOTHER UPDATEWhat I have specified in my route config is this:\[code\]routes.MapRoute(name: "Default",url: "{controller}/{id}.aspx",defaults: new { controller = "Foo", action = "Index", id = "default" });\[/code\]However, while the above route does work for Url's where Id is specified such as the ones below:\[code\]http://example.com/foo/bar.aspx\[/code\]It does not work when no Id is specified, such as in the case below:\[code\]http://example.com/foo/\[/code\]
 
Back
Top