views:

223

answers:

1

I got an issue when using jgGrid from IIS 6. My javascript looks like:

jQuery("#sandgrid").jqGrid({
    url: '/Deposit/Search?startDate=' + startDate + '&endDate=' + endDate,
    datatype: 'json',
    .....

It runs fine on my local using development web server. But when I deploy to IIS. It failed to retrieve the data, because it sent the request as http://xxx.xxx.xxx.xxx/deposit/search?... instead of http://xxx.xxx.xxx.xxx/appName/deposit/search?...

Could anybody tell me how to make it correct? BTW, I set up "Wildcard mapping" on IIS 6 to run ASP.NET MVC.

Thanks!

+1  A: 

Use this code instead:

jQuery("#sandgrid").jqGrid({
    url: '<%= Url.Action("Search", "Deposit") %>?startDate=' + startDate + '&endDate=' + endDate,
    datatype: 'json',
    .....

Url.Action() method automatically adds the virtual directory path into the URL.

Alexander Prokofyev
Thanks, Alex! But it does not seem to work. Jquery cannot recoganize MVC HtmlHelper I guess.
Liang Wu
Could you place this Javascript code into ASPX file, not separate JS file?
Alexander Prokofyev
This actually solved my problem! Thanks Alexander!
Bryan Roth