views:

96

answers:

2

Background

I have a GoDaddy shared Windows hosting plan and I'm running into a small issue with multiple domains.

Many people have previously reported such an issue, but I am not interested in trying to resolve that problem altogether; all I want to accomplish is to change the format of my ActionLinks.


Issue

Let's say the domain that is mapped to my root hosting directory is example.com. GoDaddy forces mapping of other domains to subdirectories of the root. For example, my second domain, example1.com, is mapped to example.com/example1.

I uploaded my ASP.NET MVC site to such a subdirectory, only to find that ActionLinks that are for navigation have the following format:

http://example1.com/example1/Controller/Action

In other words, even when I use the domain that is mapped to the subdirectory, the subdirectory is still used in the URL.

However, I noticed that I can also access the same path by going to:

http://example1.com/Controller/Action

(leaving out the subdirectory)


What I want to achieve

I want to have my ActionLinks automatically drop the subdirectory, as it is not required.

Is this possible without changing the ActionLinks into plain-old URLs?

+1  A: 

Hey,

No, I don't think so, as an action link mainly works to render the controller/action. The other work around, if you have install access for the server, is to use an URL Rewriting tool like iirf.codeplex.com, which is free and works pretty good. There may be some other unintended consequences with rewriting though, depending on what you are doing.

HTH.

Brian
+1  A: 

You could try adding additional route statements in your global.asax, in order from your subdirectories. Example:

routes.AddRoute("example1/{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional });
routes.AddRoute("{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional });

I believe the routes are checked in order from the global asax, so you could effectively route the request to the right spot. However, your link would still contain the 'example1' folder in the URL.

Tejs