views:

223

answers:

3

EDIT!! I should add that this site runs perfectly locally. It's only when deployed that there's this issue

ORIGINAL POST:

I have a site I just put up http://splattonet0.web704.discountasp.net/

Which loads the Index view of the Home controller just fine. However, when one clicks the links to the left, the webserver is looking for the relative paths (ie E:\web\splattonet0\htdocs\Home\AboutMe) which is incorrect, since Home folder is of course under a folder called "Views"

I've made MVC sites before and have never had this problem. I can't see any difference between this or any other site I've done.

My code in my master template for the link section is as follows:

<div id="navContainer">
            <ul id="mainNav">
                <li><a href="/Home/Index" title="Home">Home</a></li>
                <li><a href="/Home/AboutMe" title="About Us">About Me</a></li>
                <li><a href="/Skills/Index" title="Skills">Skills</a></li>
                <li><a href="/Home/Resume" title="Resume">Resume</a></li>
                <li><a href="/Home/Experience" title="Experience">Experience</a></li>
                <li><a href="/Home/SitesIveDesigned" title="Websites I've developed">My Websites</a></li>
                <li><a href="/Home/References" title="References">References</a></li>
                <li><a href="/Home/Projects" title="Projects">Projects</a></li>
                <li><a href="/Home/Hobbies" title="Hobbies">Hobbies</a></li>
                ....etc
            </ul>
        </div>

I have the same problem with and without the preceeding foreslash in the href property. I've decided to keep it there since that is how my other sites (that work!) are styled.

Can anyone shed some light on this for me? Thanks!

FURTHER EDIT:

I have been asked to provide code from an MVC site on this server I have written and that works fine. The link code in the other site (YorkCentre) is the same style: <li><a href="/Controller/Action">text</a></li>

The code:

<li><a href="/News/Index">Archived News</a></li>
<li><a href="/Home/BoardOfDirectors">Board Of Directors</a></li>
<li><a href="/Media/Index">In The Media</a>
...
</ul>
A: 

/Home/Index should be calling the "Index" action of the "Home" controller, assuming you're using default routes. The fact that "Home" is under the "Views" folder is irrelevant for MVC.

Jason
The structure under my root folder is Views\Home\Index.aspx. In my controller I have an Index() function that returns my ActionResult. I am calling the Index action of the Home controller, as described above. My problem is that on the deployed site it resolves to the wrong page.
splatto
It must be a config problem. The 404 page it returns shows that it is looking for the physical file Home\AboutMe, which sounds like the MVC routing is not enabled. Compare the IIS setups of the 2 sites. I also have an MVC site on this host, the only special step I remember is making it a VDir
Jason
A: 

If the code is the same in both locations, and the issue only happens in one, perhaps the answer lies not within the code. The following are some troubleshooting tips which may help, as I don't know exactly what the issue is without more information about the two environments.

What are the web server platforms for your local environment and the server environment? Are you using Visual Studio and Cassini locally, and IIS remotely? If so, which version of IIS? If not, what is the platform? In any event, is the target server configured correctly?

Check to make sure your routes are set up correctly on the target server. This is especially true if your target server runs IIS6 -- IIRC, IIS 6 needs some special configuration help to deal with the standard routing in ASP.NET MVC.

If all of the above don't help you trace this out, try to replicate it locally by creating a new MVC site and merely dropping your existing files into it. See if that succeeds or fails.

Do you have other successfully-executing ASP.NET MVC apps on that server? Check their configurations against your new site's.

John Rudy
Yes, I have one other site on discountASP. That required no configuration, and thus I gave this one no configuration. The weird this is when you go to the site, It renders the Index view of the home controller correctly, It's when links are clicked that the problem arises.
splatto
Well, we have an answer on target environment: Win2K8/IIS7. We don't have an answer on much else. Can you edit your post to include similar code which DID work in the target environment?
John Rudy
And perhaps a link to your other site on this host?
John Rudy
Yes, thank you. The other website is http://yorkcentreconservative.ca/if you want the ugly discountasp url it is http://yorkcentrec.web702.discountasp.net/
splatto
I have added the code requested to the original post. Thanks for your help.
splatto
A: 

I have resolved the problem! In DiscountASP I have changed the Application Pool Pipeline Mode from Classic to Integrated and that results in my views being properly rendered.

splatto
That makes sense. Did you have to do that on your first site?
John Rudy
It never ended up switched to Classic in the first place, so the problem was never there on the first site. Somehow I must have switched it to Integrated on the new site.Thanks again for your time and patience!
splatto