Reputation: 5029
My site is hosted on a server with multiple virtual directories, and I have different domain names pointing to their respective virtual directories. My site works fine in debug mode in Visual Studio where nothing unusual happens.
The URL is something like http://www.greatsite.com, but RedirectToAction links that are like this:
return RedirectToAction("Profile", "Account");
I want to go here...
http://www.greatsite.com/Account/Profile
...are going here instead:
http://www.greatsite.com/greatsite/Account/Profile
...where 'greatsite' is the name of the virtual directory.
The site is being published using FTP and the FTP address points directly into the 'greatsite' folder. So the site is published to the root as far as FTP goes.
The page displays either way. The URL points to the virtual directory, and I'm confused why they would both work.
EDIT
I eventually found the answer here: https://stackoverflow.com/questions/364637/asp-net-mvc-on-godaddy-not-working-not-primary-domain-deployment
So you might want to close this as a duplicate question, sorry. Unless someone can explain this solution in more detail.
<rewrite>
<rules>
<rule name="Remove Virtual Directory">
<match url=".*" />
<action type="Rewrite" url="{R:0}" />
</rule>
</rules>
</rewrite>
Upvotes: 1
Views: 3056
Reputation: 38608
RedirectToAction will redirect to another Action/Controller inside the current asp.net mvc application. You can redirect to an external URL using the Redirect method.
return Redirect("http://www.externalurl.com");
or another virtual directory:
return Redirect("http://www.externalurl.com/directory");
Upvotes: 1