[英]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: 但是,它会产生错误的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. 这不是我想要发回的东西,我永远都不需要appId
。 Just the Create
只是Create
How do you get around this? 您如何解决这个问题?
You can use another overload of Html.BeginForm
to explicitly specify the action you want: 您可以使用Html.BeginForm
另一个重载来显式指定所需的操作:
@using(Html.BeginForm("Create", "SomeController"))
{
}
This will not append anything to the URL by default. 默认情况下,这不会在URL后面附加任何内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.