I started working with MVC Ajax last week.  I started working though the examples found the Wrox’s Pro ASP.NET MVC

    <% using (Html.BeginForm(new { action = "HelloAjax" }))

       { %>

       <input type="text" name="query" size="40" />

       <input type="submit" value="go" />

    <%} %>


    <div id="results">



And I got this

It took about a second to understand that I didn’t have a “HelloAjax” method so I went farther into the chapter to find this:

        public string HelloAjax(string query)


            return "You entered: " + query;


That works better:


I then changed the form to AJAXify it: 

    <%using (Ajax.BeginForm("HelloAjax",

        new AjaxOptions { UpdateTargetId = "results" }))


        <%=Html.TextBox("query", null, new { size = 40 })%>

        <input type="submit" />

        <%} %>

    <div id="results">


And got it:

Which is what I expected.  I then loaded Fiddler to see the traffic

The important thing with Fiddler is that when you are using your local machine, you need to either type "localhost." (note the extra period) or the machine name.  You also need to allow Fiddler to be a proxy so you need to adjust Vista’s security settings.

I am really impressed how light weight the payload is.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: