I created a simple form that works fine when I run it in Visual Studio, but fails on my website with a 404 error.
I have an Action set up to receive only "post" messages using [HttpPost]. If I change the Acton to receive "get" messages, the Action is called, but the form information is not passed along.
This site is written with .Net MVC, could there be some kind of security or something on the server that may need to be changed to allow for "post" calls?
Controller Code -
[HttpGet] public ActionResult Tester1() { return View("Tester1"); } [HttpPost] public ActionResult Tester2(MyModel myModel) { return View("Tester2", myModel); } Tester1.cshtml Code -
@model FS.Models.MyModel @using (Html.BeginForm("Tester2", "Comics", FormMethod.Post)) { <div> Enter Text - @Html.TextBoxFor(m => m.property1) </div> <div> <input type="submit" value="SEND!" /> </div> } Tester2.cshtml Code -
@model FS.Models.MyModel You entered - @Model.property1 Global.asax.cs Code -
routes.MapRoute( "Tester2Route", // Route name "{controller}/Tester2", // URL with parameters new { controller = "Comics", action = "Tester2" } // Parameter defaults ); (the code above is just a summarized version, you can visit the actual site here - http://funkysmell.com/Comics/Tester1/)