views:

115

answers:

2

Hi

When i set my project to start app using Visual Studio Development server (Cassini:Port) my JQuery posts properly to the following URL

"SomeController/SomeMethod".

When i use localhost to run with the following URLS, it does not work

"http://localhost/Store/SomeController/SomeMethod" or "SomeController/SomeMethod".

Any one facing this kind of issue?

Thanks Joe

A: 

You can create on iis yourapp.com and in [WindoewsRoot]\System32\drivers\etc\host add line 127.0.0.1 yourapp.com and now you can test your application on this url http://yourapp.com/testpage/

Maksim Kondratyuk
+3  A: 

Try using Url.Action to map the URLs so that they are correct no matter what the virtual root.

$.post( '<%= Url.Action( "SomeMethod", "SomeController" ) %>'
        data,
        function() { ...callback.. },
        'json' );

If this still doesn't work, then we'll probably need to see your routing set up. It would also be helpful to know whether ActionLinks work but jQuery AJAX doesn't. If that's the case and the URLs are the same, then you may not have the correct urls for your Javascript files. In that case, you'd want to use Url.Content to map those URLs so they are always correct.

<script type="text/javascript"
       src='<%= Url.Content( "~/Scripts/jquery-1.3.2.js' ) %>'>
</script>
tvanfosson