Start learning with our library of video tutorials taught by experts. Get started
Viewers: in countries Watching now:
Thousands of businesses have used Microsoft ASP.NET to build professional, dynamic websites. In this course, web developer David Gassner demonstrates the tools needed to build and deploy a dynamic site using ASP.NET 3.5 or 4.5. Covering everything from installing and configuring Visual Web Developer 2008 or Visual Studio Express 2012 for Web and SQL Server Express to creating web form pages, this course is designed to give beginning and intermediate developers hands-on experience.
After creating the user interface that allows the user to login, the next step is to lock down the rest of the website so that when the user tries to navigate to any page of the website they are automatically redirected to the Login page. To see the current behavior, open the file Titles.aspx or any other web page that presents data in the site and run the page in the browser. You should see that the page loads successfully. Close the browser and return to Visual Web Developer and then open the file web.config. This is the XML file in which you configure your website's behavior.
In the file, navigate to the end of the system.web element. If you are using the version that's included with the Exercise Files, you will find that element at the line 83. Notice in the version that's included with the Exercise Files that there is a commented out section. This section isn't in there by default, I placed it in there, so it's not taking any action yet. In order to lock down the entire website, you simply create this authorization element and within the authorization element, you add a deny element with the user's attribute set to a question mark. That means that you are denying access to any anonymous users.
To complete the task of locking down the website then simply remove these comment tokens and then press Ctrl+S to save your changes to the web.config file. Now, go to Titles.aspx again and try running the page in the website. This time you should see that instead of going to the Titles page, you are redirected automatically to the Login page. Take a close look at the URL in the web browser though. Notice that you are redirected to Login.aspx and a return URL attribute is passed in that references the page you try to get to and then log in with the username and password that you have added to the authentication database earlier.
I will login with the user name and the password that I used and then I'll click the Login link and you will see that the page I originally requested, the Title list is successfully loaded. As long as I keep the browser open, I'll be able to navigate around in the website. If I close the web browser and then try to reopen a page of the website, I'll once be redirected back to the Login form. This is because the Login system is using session based cookies; cookies that are only stored in the browser's memory, rather than on disk.
So when you close the browser's windows on the client, that makes it forget the cookies and then the next time, the servers doesn't recognize the user and asks the user to login again. So now, I have created the user interface for logging in and I have also locked down the remainder of the website so only authenticated users can access those pages. The last step is to create a Logout feature, which I'll do in a separate video.
Find answers to the most frequently asked questions about ASP.NET Essential Training.
Here are the FAQs that matched your search "":
Sorry, there are no matches for your search ""—to search again, type in another word or phrase and click search.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.