views:

3467

answers:

6

I am trying to get ASP.NET MVC working on GoDaddy and I'm not having much luck. I have read the post on SO that covers the subject, but I must have a slightly different configuration or must be missing somehting along the way because the main MVC page comes up, but all links seem to fail and no amount of tweaking the URLs seems to get it to work. A little back ground. I have a single hosting plan with many domains pointed to sub folders of the main domain. Basic ASP.NET web forms pages work just fine, but of course I wanted to try and host a sample MVC site in one of these non-primary domains. You can go to the URL here. As you can see this first page comes up, but if you click on Home or About it doesn't work. Clicking on Home creates this link "http://www.jprescottsanders.com/jps/" and clicking on about creates this link "http://www.jprescottsanders.com/jps/Home/About". As you can see JPS sneaks in there, this of course is the sub folder that i place my web app files in. I would like to know if this is a MVC related issue or a GoDaddy issue. I suspect that MVC may want to sit in the root directory of the site, and when it puts the "jps" into the URLs it breaks the routing mechanisms (but this is conjecture). I know Dan said this was possible so I'm hoping he sees this and helps me get to the bottom of this deployment strategy for MVC.

+2  A: 

I followed the following instructions on Haacked's site. At the very bottom of the walk through he talks about depoloying in a virtual directory and a change that must be made in the Default.aspx.cs file. You basically need to add false in the following call:

HttpContext.Current.RewritePath(Request.ApplicationPath, false);

This seems to have resolved the bulk of my issues.

JPrescottSanders
A: 

I have the same problem as you do. I am using IIS7 so I don't need the .aspx but I've been trying to follow these directions to remove the subdirectory (/jps in your case) to no avail.

Have you corrected the rewrite path call in the Default.aspx.cs page?
JPrescottSanders
A: 

JPrescottSanders: Did it really solve it for you? Didn't work for me... i'm having the exactly same problem.

yes, following the directions in the link above i was able to solve the issue.
JPrescottSanders
A: 

Please try below:

   public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            "Default",                                              // Route name
            "",                           // URL with parameters
            new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
        );


        routes.MapRoute(
            "Default.aspx",                                              // Route name
            "{controller}.aspx/{action}/{id}",                           // URL with parameters
            new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
        );

    }
A: 

I'm a little confused I guess. If this worked how come your site still resolves all of its links with the /jps/ in the url.

http://www.jprescottsanders.com/Home.aspx/About http://www.jprescottsanders.com/jps/Home.aspx/About

These route to the same page but you have not eliminated the rendering of the /jps/.

+4  A: 

This issue actually has nothing to do with Godaddy's shared hosting. It's simply caused by hosting your site in a virtual directory. If you're using IIS7 (which is an option with Godaddy), you can use configuration-based solution listed here:

http://codebeater.com/2010/05/solution-for-asp-net-mvc-routing-issue-on-godaddy-shared-hosting/

This will completely eliminate the virtual directory name showing up in your url without having to write any code.

I will check this out, when I logged this originally IIS7 did not appear to be an option (2008). I now have cut my site over to IIS7 and no longer have the issue, but I'll check out the config settings to see what you are talking about.
JPrescottSanders
That linked worked for me.
WildJoe