简体   繁体   中英

ASP.NET MVC Url.Action creating Get not Post

I have:

public ActionResult Create(Guid appId)
{
    var vm = new CreateViewModel(appId);

    return View(vm);
}

[HttpPost]
public ActionResult Create(CreateViewModel vm)
{
    // this does some stuff
}

Now, in the View I use this for creating the Form:

@using(Html.BeginForm())
{

}

Standard.

How ever, it produces the wrong HTML:

<form action="/SomeController/Create?appId=414FDS-45F2SF-TEF234">

This is not what I want posted back, I don't want appId what so ever. Just the Create

How do you get around this?

You can use another overload of Html.BeginForm to explicitly specify the action you want:

@using(Html.BeginForm("Create", "SomeController"))
{

}

This will not append anything to the URL by default.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM