我正在尝试ASP.NET MVC2。我有一个名为SearchController的控制器和一个名为Search的视图文件夹,其中包含Search.aspx。 在我的控制,我有:asp.net mvc2表单发布不断扩展浏览器网址
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Post()
{
HPSLucene.Models.Arbitrary arb = new HPSLucene.Models.Arbitrary();
arb.Title = "Post received";
return View("Search",arb);
}
在我看来,我有:
<form action="Search/Post" method="post">
<label><% Response.Write(Model.Title); %></label>
<input type="Submit" Value="First" Name="submitButton"/>
</form>
它工作正常,我第一次点击按钮,浏览器显示的http://localhost:1824/Search/Post的URL。但是,当我第二次点击该按钮时,浏览器URL变为http://localhost:1824/Search/Search/Post,我得到了404。我做错了什么?非常感谢。
感谢,这工作。然而,在这篇文章http://weblogs.asp.net/scottgu/archive/2008/09/02/asp-net-mvc-preview-5-and-form-posting-scenarios.aspx然后斯科特格思里不使用这段代码和推测他的代码工作正常 - 任何想法这里发生了什么? – Journeyman 2011-03-28 12:33:48