Pergunta

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?

Foi útil?

Solução

I found a solution to catch base url. One can get base url with usingHttpRuntime.AppDomainAppVirtualPath as shown here.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top