Click here to Skip to main content
15,884,298 members
Articles / Web Development / ASP.NET
Article

about authentication mode in asp.net

Rate me:
Please Sign up or sign in to vote.
1.04/5 (13 votes)
7 Jun 20061 min read 62.5K   14   3
When you begin a asp.net programe,you can consider authentication that's value either 'windows' or 'forms'

Introduction

When you begin a program for a customer using asp.net ,you should consider about security.In web.config file you can set authentication mode value 'windows' or 'forms'.What's about difference and how you use then?(Authentication have other value.this artical not consider them.)

How to use mode windows

When you select this mode ,you can make all client access your project.Code like this(this case you can't get value using 'User.Identity.Name'):

<authentication mode="Windows" />

<authorization>
<allow users="*" />

</authorization>

other You can make make a special client to access you project with windows authentication.Code like this(this case you can get value using 'Use.Identity.Name',then you can use it to do other work you like.):

<authorization>
<deny users="?" />

</authorization>

How to use mode Forms

If you select 'Forms' mode.First you should specify a page and make sure all client can found it.Code like this:

<authentication mode="Forms">
<forms name="Authentication" loginUrl="LoginForForms.aspx" />
</authentication>

<location path="LoginForForms.aspx">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>

Second in that page you to validate the use's Id and Password.Code like this:

if(UserIsLogin())
{
try
{
FormsAuthentication.RedirectFromLoginPage("2", false);
}
catch (Exception ex)
{
Response.Redirect("defaultForForms.aspx");
}
}

Finally

This knowlege is simple for everybody.But i know this It's two years from i using C# and asp.net.So i write this article ,because i sure have many programer do know so many about it.This article must have lots of mistakes that I don't wake up to.So I welcome you tell me.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
China China
MY speciality is study at computer_soft develope and design. But after graduate form school,I work at a consultation company about one year.From that ,i lose work about half year.Then a work at soft company beacause one of my schoolfellow introduce.By far I study computer knowledge become more love it.
I like c\c++ and c# language. and like involved method,struct ect.
Other I have a good family :father,mother,sister,brother,and a pretty
girl friend. I live in china Tianjin.

Comments and Discussions

 
GeneralVery practical Pin
_Nic_8-Oct-09 1:51
_Nic_8-Oct-09 1:51 
GeneralGood article, but.... Pin
RichardGrimmer8-Jun-06 5:24
RichardGrimmer8-Jun-06 5:24 
*COUGH* Authentication MODE *COUGH*

Smile | :)

"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox

GeneralRe: Good article, but.... Pin
Chandrashekhar Kulkarni7-Mar-07 4:18
Chandrashekhar Kulkarni7-Mar-07 4:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.