Click here to Skip to main content
Click here to Skip to main content

about authentication mode in asp.net

, 7 Jun 2006
Rate this:
Please Sign up or sign in to vote.
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

About the Author

softprogramer
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 Pinmember_Nic_8-Oct-09 1:51 
GeneralGood article, but.... PinmemberRichardGrimmer8-Jun-06 5:24 
GeneralRe: Good article, but.... PinmemberChandrashekhar Kulkarni7-Mar-07 4:18 

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

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

| Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 7 Jun 2006
Article Copyright 2006 by softprogramer
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid