我们有一个MVC 5.1项目,正在使用属性路由。除了默认页面上有登录表单之外,其他所有内容都正常运行。
[RoutePrefix("Home")]
public class HomeController : BaseController
{
[Route("~/")]
[Route]
[Route("Index")]
[HttpGet]
public ActionResult Index()
{
var model = new LoginViewModel();
return View(model);
}
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Index(String Username, String Password)
表单通过GET罚款显示,但在POST上我们得到...
HTTP错误405.0-不允许的方法
您正在寻找的页面无法显示,因为正在使用无效的方法(HTTP动词)。
通常,默认路由将同时处理POST和GET罚款。
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}/{dealerId}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
显然,由于其他页面上的后续帖子可以正常工作,因此默认路由中的帖子在路由中缺少某些内容。
有人这样做吗?
谢谢,
好吧,我要做的就是添加
[Route("~/")]
[Route]
[Route("Index")]
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Index(String Username, String Password)
真的很明显!漫长的一天!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句