Ugly URLs when an ASP .NET MVC app is hosted in a virtual directory
I am using Godaddy Deluxe hosting which allows me to host several websites in a single hosting account. The main website is hosted in the root of the hosting account and the rest of the websites are hosted in a subfolder in the form /hosting/websitename.
If I deploy an MVC app under a virtual directory, I get ugly looking URLs like:
http://www.mywebsite.com/hosting/mywebsite/Home/About
Note the /hosting/mywebsite part. For some reason the Html.ActionLink helper method infers the real hosti开发者_如何学Gong path which is exactly what I want to avoid. The URL should look like:
http://www.mywebsite.com/Home/About
The problem is easily reproducible by creating a new MVC application and changing the folder of the dev server from root (/) to something else (such as /hosting/).
How can I go about that apart from purchasing a new Godaddy hosting account?
Although not the definitive answer, there is a hack that does the trick. It's posted right here on SO.
Do you need to run multiple sites in your account? If not, ask godaddy how to make your MVC site the root.
This is easily fixable from a techinical level, but not with the constraints that you indicate exist at GoDaddy.
Ok, I'm not personally familiar with godaddy's hosting options, but your best bet might well be to take your business elsewhere where you can have multiple root-running applications as GoDaddy seems a bit limiting here. Or just purchasing a separate account for the application if you want to get expedient.
I've used GoDaddy quite a bit but I have yet to do this exact scenario you mentioned, but...
Have you tried to go to "IIS Management" from the control panel and set whatever directory your serving your MVC app from to the application root? I believe you just click on the edit button for the virtual directory and a dropdown appears where you can set that directory as an application root. Let me know if that works.
精彩评论