0

If I use a maproute like

routes.MapRoute(
        name: "Default",
        url: "{controller}/{action}/{id}",
        defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
    );

The resulting url of Url.Action("","") is like www.mysite.com/ which is base url of my site. but when I use the one with asterisk like

routes.MapRoute(
        name: "Default",
        url: "{controller}/{action}/{*id}",
        defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
    );

The resulting url of Url.Action("","") is like www.mysite.com/Home/Index/, but in second case I want to obtain www.mysite.com/ which is my base url. What should I do for that?

4

1 回答 1

0

我找到了一个捕获基本 url 的解决方案。可以使用这里HttpRuntime.AppDomainAppVirtualPath所示的方式获取基本 url 。

于 2013-07-28T11:07:26.640 回答