0

I currently have the following within my view

function loadData() {
     var url = "/Testx.mvc/GetData";
     var id = "111111";
     var format = "html";

     $.ajax({
         url: url,
         type: "POST",
         dataType: format,
         data: "id=" + id,
         success: populateResults
     });
 }

 function populateResults(result) {
     $('#results').html(result);
 }

I also have a controller called TestxController with an action method called GetData(int? id). Now the ajax call above works on Visual Studios 2008's built-in development server, but when i switch it to use IIS webserver it doesn't. It seems like the route isn't being found because I tried putting a break point on GetData but it doesn't even reach there. Does anyone know what i would need to do to fix this?

Edit: I've also tried the wildcard mapping method discussed at http://haacked.com/archive/2008/11/26/asp.net-mvc-on-iis-6-walkthrough.aspx and it worked perfectly. (Of course I had to remov the .mvc from the url) Is there any way to get this to work with the .mvc extension?

Thanks

8
  • 1
    nevermind me. feeling dizzy. answer was completely lame. ^^ Commented Dec 4, 2009 at 0:05
  • Some tips=>use $.get, use JSON to pass data (data: {id:id}), use <a href="haacked.com/archive/2008/03/13/url-routing-debugger.aspx" title="route debugger">route debugger</a>. Might be useful. Commented Dec 4, 2009 at 0:10
  • Screw it. I don't understand how to format hyper-link nicely in comments. Commented Dec 4, 2009 at 0:12
  • 1
    You could use FireBug's console to see the ajax request being made, then check what the response from the server was. My guess is it's most likely a problem with the ISAPI rule for the .mvc extension in IIS. Commented Dec 4, 2009 at 0:12
  • Yeah. I second to Rudism. This sounds like a real answer. Here's a link with how-to: haacked.com/archive/2008/11/26/… Commented Dec 4, 2009 at 0:14

2 Answers 2

1

Is Testx.mvc at the root of your webserver? If your application is running in a virtual directory on IIS then the correct path would be something like /YourApp/Testx.mvc/GetData.

The Visual Studio built-in webserver might be placing Testx.mvc at root, which is why it works within VS.

If that is the case, then try using the relative path Testx.mvc/GetData rather than /Testx.mvc/GetData.

Sign up to request clarification or add additional context in comments.

Comments

0

Is there an actual function called 'callback'? Just asking because it seems like you might mean to be calling 'populateResults' with a successful response.

Try this perhaps:

$.ajax({
     url: url,
     type: "POST",
     dataType: format,
     data: "id=" + id,
     success: function(results){$('#results').html(result)}
 });

Did you check your ISS setup to see if it supports the POST action? It might only be specifying the GET action... see http://haacked.com/images/haacked_com/WindowsLiveWriter/07de283cb368_B754/application-mappings_3.png

1 Comment

Yeah that didn't change anything. Thanks though

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.