将表单发布到控制器操作在生产环境中不起作用
两天来我一直在努力解决这个问题,但没有快乐。
我有一个简单的表单,可以发布到控制器操作。表单发布,但它似乎没有通过控制器操作例程,因为没有发生验证或表单字段绑定 - 在开发环境中,字段是从请求填充的(我假设是由助手)并显示验证摘要。
Html
<form method="post" action="/Contact">...fields and submit...</form>
控制器
[HttpPost]
public ActionResult Contact(ContactModel model)
{
View(model);
}
当我在回发后刷新页面时,我不会被要求重新发布这些值,这让我认为某个地方正在导致重定向,但这在开发环境中不会发生。
有人有什么好主意吗?错误记录器似乎没有在幕后报告任何 500 错误,因此没有任何帮助。
2 days I've been trying to get my head around this, but no joy.
I have a simple form that posts to a controller action. The form posts, but it doesn't appear to go through the controller action routine as no validation or form field binding occurs - on the dev environment, the fields are populated from the request (I assume by the helper) and validation summary is displayed.
Html
<form method="post" action="/Contact">...fields and submit...</form>
Controller
[HttpPost]
public ActionResult Contact(ContactModel model)
{
View(model);
}
When I refresh the page after a post back, I don't get asked to re-post the values which makes me think something somewhere is causing a redirect but this doesn't happen in the dev env.
Anyone have any bright ideas? The error logger doesn't seem to report any 500's behind the scenes so nothing there to help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这都是因为最后少了/(斜线)……上面的好心人才知道为什么。
已更新以包含代码
请注意操作属性末尾的斜杠。
This was all due to missing / (slash) at the end... The good lord above only knows why.
Updated to include code
Note the slash at the end of the action attribute.