I have deployed a mvc3 application in web. How can i add Virtual directory name in Url.Action() method ?
for eg : my application is in mydomain.com\app
now when i do
Url.Action returns action="/Home/Create" but what i want is action = "/app/Home/Create".
What should be done ?
You shouldn't need to do that. If your application is properly deployed in IIS inside a virtual directory (say App
) then the Url.Action("Create", "Home")
helper will generate /app/home/Create
which is the correct url.
Map a route (NOTE: this route has to appear BEFORE the default route)
context.MapRoute(
name: "app",
url: "app/{controller}/{action}/{id}",
defaults: new { controller = "Test", action = "Index", id = UrlParameter.Optional }
);
Then use Url.Action like this (should give you /app):
@Url.Action("Index", "Test")
You can find routes in your Global.asax.cs file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With