Get “Default” Route Url in Controller

你说的曾经没有我的故事 提交于 2019-12-05 18:37:54

A route can match any number of urls. So a route doesn't have a url. To get a url from a route you will have to supply it with the route data that you want the url for. To do that you simply use the RouteUrl() method on the Url property, Url.RouteUrl().

Update

If you want the url that will be generated if you supply the route with its default values you can do something like this:

var url = Url.RouteUrl("Default", ((Route)RouteTable.Routes["Default"]).Defaults);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!