I found a solution to catch base url. One can get base url with usingHttpRuntime.AppDomainAppVirtualPath
as shown here.
catching base url when using catchall maproute of asp .net mvc
-
04-06-2022 - |
سؤال
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?
المحلول
لا تنتمي إلى StackOverflow