Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.Net MVC Controller not being called
    text
    copied!<p>I have a MasterPage, in my Views\Shared folder. I have an index.aspx in my Views\Home folder. And I have a login.ascx (user control) in my Views\User folder. The ascx file is added to my MasterPage:</p> <pre><code>&lt;% Html.RenderPartial(@"~\Views\User\login.ascx");%&gt; </code></pre> <p>The code in the ascx is pointing the submit form to a UserController.cs in my Controllers folder.</p> <p>Here's the ascx:</p> <pre><code>&lt;%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl&lt;BudgieMoneySite.Models.SiteUserLoginModel&gt;" %&gt; &lt;% using (Html.BeginForm("UserLogin", "User")) {%&gt; &lt;table width="300"&gt; &lt;tr&gt; &lt;td colspan="3" align="center"&gt; User Login &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="right"&gt; &lt;%=Html.LabelFor(m =&gt; m.Username)%&gt; &lt;/td&gt; &lt;td&gt; &lt;%=Html.TextBoxFor(m =&gt; m.Username)%&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="right"&gt; &lt;%=Html.LabelFor(m =&gt; m.Password)%&gt; &lt;/td&gt; &lt;td&gt; &lt;%=Html.PasswordFor(m =&gt; m.Password)%&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;%=Html.CheckBoxFor(m =&gt; m.RemeberMe)%&gt;&lt;%=Html.LabelFor(m =&gt; m.RemeberMe)%&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="2"&gt; &lt;/td&gt; &lt;td colspan="3" align="right"&gt; &lt;input id="Submit1" type="submit" runat="server" value="Login" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;% } // End Using.%&gt; </code></pre> <p>If I ctrl+click the Controller name and the method, in the Html.BeginForm area, it takes me to my method that should be called when I click Sybmit.</p> <p>The method that this should call, in my UserController, has this code defined:</p> <pre><code> [HttpPost] public ActionResult UserLogin(SiteUserLoginModel model) { try { if (MembershipService.ValidateUser(model.Username, model.Password)) { FormService.SignIn(model.Username, model.RemeberMe); PersonDto user = SiteUserLoginModel.LoadLoggedInUserDetails(model.Username); Session.Add("current_firstname", user.Firstname); Session.Add("current_userid", user.PersonId); } return RedirectToAction("Index", "Home"); } catch (ArgumentException e) { ViewData["ErrorMessage"] = e.Message; return RedirectToAction("Index", "Home"); } } </code></pre> <p>However, when I click the submit button at runtime, this method is never called. The screen just refreshed. The HomeController does fire though, as the index screen is refreshed, I think. But the breakpoint in my method above never fires.</p> <p>What am I doing wrong?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload