BeginUmbracoForm没有渲染动作

问题描述:

我尝试使用mvc umbraco创建简单的登录窗体,但是由于BeginUmbracoForm没有输出动作名称,所以它没有敲击控制器。无法弄清楚为什么没有。BeginUmbracoForm没有渲染动作

下面是我的代码

查看

<h3> Login</h3> 

       @using (Html.BeginUmbracoForm("SubmitLogin", "Login", System.Web.Mvc.FormMethod.Post, new { id = "login" })) 
       { 
        @Html.AntiForgeryToken() 
        @Html.ValidationSummary(true, "", new { @class = "alert text-danger" }) 
        <form> 
         <!-- Text input--> 
         <div class="form-group"> 

          @Html.LabelFor(m => m.Email, new { @class = "control-label" })<span class="required">*</span> 
          @Html.TextBoxFor(m => m.Email, new { @class = "form-control input-md0", required = "required", type = "email" }) 
          @Html.ValidationMessageFor(m => m.Email, "", new { @class = "text-danger" }) 
         </div> 
         <!-- Text input--> 
         <div class="form-group"> 
          @Html.LabelFor(m => m.Password, new { @class = "control-label" })<span class="required">*</span> 
          @Html.TextBoxFor(m => m.Password, new { @class = "form-control input-md", required = "required", type = "password" }) 
         </div> 

         <!-- Button --> 
         <div class="form-group"> 
          @Html.ValidationSummary() 
          <button id="submit" name="submit" type="submit" class="btn btn-primary btn-lg">Login</button> 
          <a href="forget-password.html" class="pull-right"> <small>Forgot Password ?</small></a> 
         </div> 
        </form> 




       } 

控制器

public class LoginController : SurfaceController 
    { 

     // GET: /Login/  
     public ActionResult RenderLogin() 
     { 
      var model =new LoginModel(); 
      return PartialView("~/Views/Partials/Forms/LoginForm.cshtml", model); 
     } 


     [HttpPost] 
     [ActionName("SubmitLogin")] 
     [ValidateAntiForgeryToken] 
     public ActionResult SubmitLogin(LoginModel model, string returnUrl) 
     { 
      if (ModelState.IsValid) 
      { 
       if (Membership.ValidateUser(model.UserName, model.Password)) 
       { 
        FormsAuthentication.SetAuthCookie(model.UserName, false); 
        UrlHelper myHelper = new UrlHelper(HttpContext.Request.RequestContext); 
        if (myHelper.IsLocalUrl(returnUrl)) 
        { 
         return Redirect(returnUrl); 
        } 
        else 
        { 
         return Redirect("/login/"); 
        } 
       } 
       else 
       { 
        ModelState.AddModelError("", "The username or password provided is incorrect."); 
       } 
      } 
      return CurrentUmbracoPage(); 
     } 

} 

HTML输出

<form action="/login" enctype="multipart/form-data" id="login" method="post"> 

试试这个:

@using (Html.BeginUmbracoForm<LoginController>("SubmitLogin", new { id = "login" })) { 

} 

这也将是值得检讨的BeginUmbracoForm重载和文档在这里:

https://our.umbraco.org/Documentation/Reference/Templating/Mvc/Forms