c# - Html.BeginForm not triggering Controller Action -
i'm new programming , c#/asp.net mvc , i've been trying while work , i'm running out of ideas. i've tried find answer online haven't come solution yet (even after reading , trying methods found similar questions). forum little intimidating posting new things i'm stuck right now. figured i'd give shot.
i have project i'm making in i'm using bootstrap, asp.net , c# create webpage e-commerce-like site. i'm working on login system. i'm using simplemembership , trying create login form not need new page solely login, it's on shared view.
here's view form login partial:
@model fakestore.viewmodels.menusuperiormodel <form class="navbar-form navbar-right"> @if (!websecurity.isauthenticated) { using (html.beginform("autentica", "login", formmethod.post)) { <div class="form-group"> @html.textboxfor(m => m.login, new { @class="form-control", placeholder="login" }) </div> <div class="form-group"> @html.textboxfor(m => m.senha, new { @class ="form-control", placeholder="senha"}) </div> @html.hiddenfor(m => m.carrinhocount) <input type="submit" value="sign in" class="btn btn-success" /> <a class="btn btn-success" href="~/usuario/form">register</a> } } else if (websecurity.isauthenticated) { <span class="label label-primary">welcome, @(websecurity.currentusername)!</span> } </form>
that view child of partial view on layout page.
this partial view calls login form view:
<nav class="navbar navbar-inverse navbar-fixed-top"> <div class="container"> @html.partial("_carrinhocompratopmenu") <div id="navbar" class="navbar-collapse collapse"> <!-- vamos ver se dá problema esse _loginmenu --> @html.partial("_loginmenu") </div><!--/.navbar-collapse --> </div> </nav>
here's controller action beginform's method should calling:
public class logincontroller : controller { // get: login private usuariodao udao; public logincontroller(usuariodao udao) { this.udao = udao; if (!websecurity.initialized) { websecurity.initializedatabaseconnection("stoneecommerce", "usuario", "id", "login", true); } } public actionresult index() { return view(); } [httppost] public actionresult autentica(menusuperiormodel menusuperiormodel) { if (websecurity.login(menusuperiormodel.login, menusuperiormodel.senha)) { return redirecttoaction("form", "produto"); } else modelstate.addmodelerror("login.invalido", "login ou senha incorretos"); return view("index"); } public actionresult loginmenu() { return partialview("_loginmenu"); }
i'm trying submit button send menusuperiormodel logincontroller's action autentica can authenticate user. thing it's not getting action. tried setting breakpoint on , action isn't being called. missing something? appreciate help.
ps: have no custom routes configured.
you have nested forms invalid html , not supported. remove outer <form class="navbar-form navbar-right">
element.