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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Elliot Balynn's Blog

A directory of wonderful thoughts

Software Engineering

Web development

Disparate Opinions

Various tidbits

chsakell's Blog


Once Upon a Camayoc

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

%d bloggers like this: