图路线
char name[100], state[100]; // at least same size as line - length of label
....
s = getField(statusf, "State:", 6, state);
n = getField(statusf, "Name:", 5, name);
行动方法
routes.MapRoute(
name: "ContactForm",
url: "contact-form.html",
defaults: new { controller = "SiteHome", action = "ContactForm" },
namespaces: new[] { "Presentation.Controllers" }
);
联系表格代码
[AllowAnonymous]
[AcceptVerbs(HttpVerbs.Post)]
[ValidateAntiForgeryToken]
public ActionResult ContactForm(ContactForm postForm)
{
}
当我发布我的表单时...我删除了AntiForgeryToken()并测试了相同的结果。
HTTP错误404.0 - 未找到
答案 0 :(得分:0)
您的ActionResult名称为“ContactForm”,但您发布了
@using (Html.BeginForm("IletisimForm", "SiteAnasayfa", FormMethod.Post, htmlAttributes: new { @class = "" }))
一定是;
@using (Html.BeginForm("ActionName", "ControllerName", FormMethod.Post, htmlAttributes: new { @class = "" }))
你的路线就像;
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
你的行动就像;
[HttpPost]
public ActionResult ContactForm(ContactForm postForm)
{
}
并删除AntiForgeryToken,如果您发布数据,可以稍后添加。