13.07.2015 Views

ASP.NET 3.5: A Beginner's Guide - www.mustafaof.com

ASP.NET 3.5: A Beginner's Guide - www.mustafaof.com

ASP.NET 3.5: A Beginner's Guide - www.mustafaof.com

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 16: Security 397Figure 16-4 Login page appears automaticallyon a production server. The full path for an IIS server on your <strong>com</strong>puter would be OS(C:)> inetpub > <strong>www</strong>root.Once everything is in place, open your browser and navigate to an <strong>ASP</strong>X file. As soonas you do, you will be redirected to the Login file as shown in Figure 16-4. If you put inan incorrect username or password, you will see the message that your attempt failed.Ask the ExpertQ: Isn’t it risky to put the login name and password in the C# code? Wouldn’t it befairly easy for a hacker to get those?A: You bet! The C# portion of the login example is to illustrate how theFormsAuthentication class can be used to send the requested URL to theuser after she has successfully logged in. Besides being a fairly risky way ofprotecting a username and password, it’s awkward to store username and passwordinformation in a coded format. Imagine a site that has thousands of users. So keepin mind that the login example is to show how the web.config file can redirecta request to a login page and how the FormsAuthentication class sends thelogged-in user to the requested URL.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!