How to create a login page using ASP.NET MVC 3 Razor (1 of 5)

preview_player
Показать описание
Simple example of how to create an MVC 3 Razor web application that forces a users to login in order to access secure parts of the website.

Outline:
1. In Visual Studio 2010, create an empty ASP.NET MVC 3 Razor application
2. Create a Home Controller
3. Create a Model for the Login data using Data Annotations
4. Create a Login Controller
5. Create an method decorated with the HttpPost attribute
6. Create a View for the Login HTML Form
7. Use Razor @Html helpers to build the HTML Form
8. Discuss Client-side and Server-side validation
9. Update Web.Config file to allow and disallow anonymous users
10. Update Web.Config to force users to the Login View
11. Create a Layout (Master) page for anonymous users and a different Layout for authenticated users
Рекомендации по теме
Комментарии
Автор

Great vids! So clear and understandable. Surprisingly better than most videos made to teach others...

TriStarGOD
Автор

Simple and clear. Thanx alot for the tutorial man.

raathigesh
Автор

This tutorial just saved my life! (or at least, saved my project!) lol

Thanks A LOT!!

marcelomyara
Автор

thanks for explaining everything so well! really easy to follow.

punkholiday
Автор

Great Job. Very useful set of tutorial :) thanks alot :)

raathigesh
Автор

Really great tutorial! Thanks man! Means a lot to me! :)

Bobby.Kristensen
Автор

Awesome tutorial jalbao! However, the "script" tags should go in the "head" for structure, you could've made a tutorial, in this tutorial using @sections. that'd be pretty cool :)

royalpie
Автор

@dhtroy .. I'm glad you found the video useful. The software that I used is Techsmith's Camtasia Studio... An awesome product worth every penny.

jalbao
Автор

Hi! First of all thanks for uploading the video, is way too clear and easy to understand. I just have a question, after applying what you explained in my project, ReturnUrl is always null, even though the URL is different from zero. I was thinking of using this parameter to redirect the user to the value that has ReturnUrl, but I find the surprise is always zero, then you know how to get that parameter? Perhaps to be declared somewhere in the project.

Stay tuned for your comments.
Best regard

ataucare
Автор

Hi jalbao,

Thanks for the very helpful tutorial. I just had 1 problem though. I use partial views in so many places. So when the session times out, and if I click on something which loads a partial view, it loads the login in the partial view. Is there a way to redirect the main view to login page?

AnkitPatel
Автор

@fill0000 - When you go to File > New > Project (in Visual Studio), make sure you choose to create a new "Visual C#" project - not a "Visual Basic" project.

jalbao
Автор

Sir I have one Question .... Which kind of Authentication is done in this video ???

trilokpathak
Автор

Could you please explain, how can we do control access in mvc?

cengizceylan
Автор

dude! i'm tryin' to learn with u tutorial but when im tryin' to put this part:
"[httppost] 
        Public ActionResult login{loginmodel model}" my visual studio 2012 show me this like an error i'm doing something wrong or in vs 2012 change something...

Samic
Автор

Hey, im trying to do the same but with MVC4 and i cant find the scripts folder, anyone knows what the matter?

a
Автор

Choice "Basic" in the Project Template Window.

GabrielBenzaquen
Автор

Visual Studio Express is a free download from MS

DIGWoodWorks
Автор

@samwood2006 - The files/sourcecode are/is available at razorlogin .codeplex .com

jalbao
Автор

I'm unclear what you mean by "it loads the login in the partial view". I might be able to help you if you send me a MVC/Razor Solution that reproduces the problem that you are trying to explain. If you are up for this, send it to my gmail (jalbao).

jalbao
Автор

it's too small @@, i can't see what you code

avocado
join shbcf.ru