About Andras Nemes
I'm a .NET/Java developer living and working in Stockholm, Sweden.

2 Responses to Introduction to Forms based authentication in .NET4.5 MVC4 with C# Part 2

  1. Subash says:

    Thank you for these articles…i’m learning a lot as the step by step approach you follow to explain is very very clear… however having said that i have a question in one of the above steps.
    Under the register action method there is 2 lines of code as you mentioned
    WebSecurity.CreateUserAndAccount(model.UserName, model.Password);
    WebSecurity.Login(model.UserName, model.Password);

    You also said that after the login is verified the WebSecurity.Login() method logs in the user to the web application. I was wondering how did it redirect to the HomeControllers Login Action method when there is no such call in the WebSecurity.Login() method

    and also the next line of code after that is actually
    return RedirectToAction(“Index”, “Home”);

    • Andras Nemes says:

      Hi Subash,

      It’s the call to return RedirectToLocal(returnUrl); that does the redirect if the login is successful. If not then an exception message is attached to the model in the ModelState.AddModelError call.
      //Andras

Leave a comment

Elliot Balynn's Blog

A directory of wonderful thoughts

Software Engineering

Web development

Disparate Opinions

Various tidbits

chsakell's Blog

WEB APPLICATION DEVELOPMENT TUTORIALS WITH OPEN-SOURCE PROJECTS

Once Upon a Camayoc

Bite-size insight on Cyber Security for the not too technical.