asp.net mvc - Login Form in first page MVC -


I had to earn entry to enter the entry form on the site (like Gmail), then when users go to the site, most First it is the login form.

I entered these codes in the Home Controller:

  Public Sector Home Controller: Controller {Public Performance Index () {Return View (); // (see) ~ / scene / home / index.cshtml} [htmlgate] public action result log in () {return see (); // (see) ~ / view / home / logged insmtmt} [hppost] public action result log (model user aporabic) {if (ModelState. ISI walid) {if (Isvidid (Aporabic. User name, Aporbic. Password)) {form attestation .SetAuthCookie (uporabnik.Username, false); Redirect Return Action ("Login in", "Home"); } Other {ModelState.AddModelError ("", "Error!"); }} See Return (Aporbic); // (see) ~ / scene / home / logged in. Cshtml} Public Operations Log () {Form attestation. Signature (); Redirect Action ("Index", "Home"); } Private Bool ISIIDID (String User SOL) {...}   

This code is in Map View / Home:

Index.cshtml

  @modelmimodel @ {ViewBag.Title = "index"; } & Lt ;! DOCTYPE html & gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; Meta charset = "UTF-8" & gt; & Lt; Title & gt; Solr-real & lt; / Title & gt; & Lt; Link rel = "stylesheet" media = "screen" href = "../ content / site.css" /> & Lt; / Head & gt; & Lt; Body & gt; @Usage (Html.BeginForm ("Login", "Home")) {& lt; Div class = "prijavno-okno" & gt; & Lt; Fieldset & gt; & Lt; Legend & gt; Entry form: & lt; / Legend & gt; & Lt; Form method = "get" & gt; & Lt; Label & gt; Username: & lt; / Labels & gt; @ Html.TextBoxFor (u = & gt; u.Username) & lt; Br / & gt; & Lt; Label & gt; Password: & lt; / Label & gt; @ Html.PasswordFor (u = & gt; U. password) & lt; Br / & gt; & Lt; Input class = "dome" type = "submit" value = "login" & gt; & Lt; / Form & gt; & Lt; / Fieldset & gt; & Lt; / Div & gt; } & Lt; / Body & gt; & Lt; / Html & gt;   

Logged in. Cshtml

  @ {ViewBag.Title = "Login in"; Layout = "~ / scene / share / _Layout.cshtml"; } & Lt; H2 & gt; Logged in & lt; / H2 & gt;   

Login.cshtml

  @ {ViewBag.Title = "Login"; } & Lt; H2 & gt; Error & lt; / H2 & gt; @ Html.ActionLink ("back", "index", "home")   

The problem is, when I click the login button (after entering the username and password , User databases on the manual) the page remains in the first login page ... what is it?

Thank you in advance.

You must create using the form tag if you put the action name in the code Can use:

  @using (HTML.BeginForm ("ActionName", "Controller")) {... // your exising code}   

You should also rewrite your inner form code, so its use and for example

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -