JSON call + .net works in debug mode on inbuilt web server but not by going to virtual dir directly

StackOverflow https://stackoverflow.com/questions/215160

Question

I have the following javascript:

$.ajax({
type: "POST",
dataType: "json",
url: "/Home/Submit",
data: { email: strEmail, message: strMessage },
success: function(result)
{
//alert('here');
alert(result.message);
},
error: function(error) {
alert(error);
}
});

This makes a call to this function:

public JsonResult Submit(string Email, string Message)
{

return Json(new {message="yep"});
}

This works fine in debug mode on the inbuilt webserver.

However if I go to the virtual dir directly it does not and hits the error bit. I attached to the process and the code behind never gets hit.

I am using Vista.

Additionally how do you get the error description in the bit where it says alert(error);

Thanks,

Alex

Was it helpful?

Solution

Is your virtual directory at the root of the web server? The path you are supplying is rooted and won't work if your virtual directory is not at the root.

OTHER TIPS

is your virtual server running on Windows 2003 and IIS 6.0? Or is it Windows 2008 and IIS 7.0. Also the inbuilt server you are talking about is it the Visual Studio server or IIS 7.0 from Windows Vista? This all matters. With IIS 6.0 you need to run all requests through .NET with a wildcard.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top