views:

149

answers:

1

I am using an ajax form trying to post back the the CustomerController using the Create method. Here is the code

<% using (Ajax.BeginForm("Create", "Customer", new AjaxOptions { LoadingElementId = "saving"}, new { @class = "block_content form" }))
        {%>...

When my html form renders the form looks like this

<form onsubmit="Sys.Mvc.AsyncForm.handleSubmit(this, new Sys.UI.DomEvent(event), { insertionMode: Sys.Mvc.InsertionMode.replace, loadingElementId: 'saving', onComplete: Function.createDelegate(this, $j('#accoutcreate').dialog('close')) });" onclick="Sys.Mvc.AsyncForm.handleClick(this, new Sys.UI.DomEvent(event));" method="post" class="block_content form" action="/Job/Create?Length=3"> ...

As you can see the form is actually being posted to /Job/Create instead of /Customer/Create

I am not sure why this is happening. Any ideas?

A: 

Is it possible you have a route setup in the Global.asax that maps "\Job" requests to the "CustomerController"? If so, the routing engine in MVC would return "\Job" as the URL in order to keep URLs consistent.

The route would look something like this:

        routes.MapRoute("Name", "Job/Create", new { controller = "Customer", action = "Create" });
Matthew Kubicina