views:

52

answers:

3

Hi,

I have been developing an asp.net mvc application where i need to make large amounts of jquery post and get request to call controller methods and get back json result. Everything is working fine.

The problem is i had to write different jquery post and get request url on local intranet(deployed by making virtual directory) and live server.

the current jquery request url is given as below:

$.post("/ProjectsChat/GetMessages", { roomId: 24 },..........

now this format of url for jquery request works fine for live server but not for local intranet. Since on local intranet i have made a virtual directory. It only works when i append the name of the virtual directory like this "$.post("MyProjectVirutalDirName/ProjectsChat..................."

I am sure most of you must have come across same problem.

now i have made a full project, there are large number of jquery requests made, i want to test the application by deploying on local intranet and fix the bugs. Changing all the jquery requests for local intranet doesn't seem feasible solution to me, i am really in a big problem, i can't deploy the same project on live server just like that and test it there, client will kill me.

I need some expert advice.

Please help

Thanks

A: 

To avoid this problem, and many similars I have setup and run locally iis5.1

I suggest to make the same for not so small projects. You can make your development better and faster because you do not need to run the visual studio on debug mode every time to see whats change, you just see your pages on browser, and programming on visual studio.

If you need to debug a part of your code, you can do attach to process, or just drop this line of code and your program start the debugging Debug.Assert(false);

Hope this help.

Aristos
A: 

I would suggest you to avoid hardcoding urls in your javascript. The problems you are encountering is one of the reasons, the other is if you decide to change your routes. Here's what you could do instead. Define a global javascript variable inside the view that will hold the address and it will be calculated using html helpers:

var messagesAddress = '<%= Url.RouteUrl(new { controller = "ProjectsChat", action = "GetMessages" }) %>';

And then use this variable inside your script:

$.post(messagesAddress, { roomId: 24 },..........
Darin Dimitrov
A: 

Use a base tag in your master page header and change it as required...

<base href="http://site/MyProjectVirutalDirName"&gt;&lt;/base&gt;

this is a quick fix and means you dont have to go through all of your code

Mark