Hello guys and girls
Been working on a ASP.NET MVC 2 solution for some time now and today I decided to test in in the IIS7 so I could put in on a company server for my colleagues to play with.
However I got quite a surprise when I hosted it. I started to get Javascript errors in code that worked while running it locally in my VS2010.
I was actually getting errors on the initial jQuery command in my script tag, that looks like this
<script language="javascript" type="text/javascript">
$(document).ready(function () {
SetCSS();
});
So I was searching around and found this post :
My URL was "http://localhost/MVCAjaxJson" I have changed this to "http://localhost/MVCAjaxJson/" and it started working looks like a “/” at the end is required for the call back function. – Prasanth Mar 23 at 11:43
So I tried to add the forward slash to my page so it read
That solved the Javascript errors, which is fine and all.
But since I use normal routing e.g
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Account", action = "LogOff", id = UrlParameter.Optional } // Parameter defaults
);
I don't have that additional forward slash on my (action)Links which will make the Javascript run without errors. This must be something other people have experienced since I presume most use standard routing and also some form of Javascript, jQuery or not. So is there a work around or a neat trick this to working properly.
Any help is highly appreciated.
Thomas
Blockquote