I got it all working properly and now I have just been working on getting it deployed onto a test server. This is when I realised that Production is running IIS6.
So I fire up Google and search for running MVC 2 apps on IIS6 and found a lot of great advice, in particular Phil Haack's great walk through on ASP.NET MCV on IIS 6 which was most helpful on getting the routing working MVC style.
However I ran into a problem when I started to try and navigate through my Partial Views, of which I had a few all working on a single page using Ajax. I found that the ActionLink's didn't work how I had anticipated as I had set them to replace the contents of a particular div. Instead they rendered as a new page.
I tried Googling this issue and nothing seemed to come up anywhere, so I looked a little closer in my application. I opened up the Internet Explorer 8 Developer Tools and found that I was getting a Javascript Error:
Line: 90A quick Google bought up a whole bunch of results talking about Script Managers and not having the latest version of ASP.NET AJAX Extensions, but checking through these wielded no success.
Error: 'Sys' is undefined
Again to IE8 Developer Tools. I opened up the Script tab in the Developer Tools and found the drop down list of all the Scripts on the page.
What I noticed was this:
The first set of entries (above the divider) was for the address of the page. http://localhost/<site name>/Home.
And the second set of entries (below the divider) was the address of the list of scripts that were referenced by the page. http://localhost/Scripts.
This reveled the problem immediately as the scripts address was missing the <site name> in the URL.
My problems lay in the head tag of my MasterPage and the way that IIS6 performs the
routing.
The standard markup that comes out of the box is:
<script src="../../Scripts/MicrosoftAjax.debug.js" type="text/javascript"></script>Whereas to get it working I needed to remove the first ../ from the src property in each of the script tags:
<script src="../../Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script>
<script src="../../Scripts/MicrosoftAjax.js" type="text/javascript"></script>
<script src="../../Scripts/MicrosoftMvcAjax.debug.js" type="text/javascript"></script>
<script src="../../Scripts/jquery-1.4.1.min-vsdoc.js" type="text/javascript"></script>
<script src="../../Scripts/jquery-ui-1.8rc3.custom.min.js" type="text/javascript"></script>
<script src="../Scripts/MicrosoftAjax.debug.js" type="text/javascript"></script>This resulted in the script files being properly referenced and everything just worked as if by magic.
<script src="../Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script>
<script src="../Scripts/MicrosoftAjax.js" type="text/javascript"></script>
<script src="../Scripts/MicrosoftMvcAjax.debug.js" type="text/javascript"></script>
<script src="../Scripts/jquery-1.4.1.min-vsdoc.js" type="text/javascript"></script>
<script src="../Scripts/jquery-ui-1.8rc3.custom.min.js" type="text/javascript"></script>
I hope that this can be a help for anyone else that has experienced the same problem.
No comments:
Post a Comment