| | |
Forms Authentication
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2008
Posts: 324
Reputation:
Solved Threads: 7
WEB.CONFIG FIlE
FRMLOGIN.aspx
FRMWELCOME.aspx
Suppose i enter sonia in username & citm123 in password. I will be redirected to FrmWelcome. Suppose now the user copies the URL of FrmWelcome & open in other window,i want that the user is navigated to FrmLogin. How to do it.Using Cookies??? Can somebody help me out!
ASP.NET Syntax (Toggle Plain Text)
<?xml version="1.0"?> <configuration> <appSettings/> <connectionStrings/> <system.web> <authentication mode ="Forms"> <forms loginUrl="FrmLogin.aspx" protection="All" > <credentials passwordFormat="Clear"> <user name="sonia" password="citm123"/> <user name="soni" password="citm123" /> <user name="muru" password="citm1234"/> </credentials> </forms> </authentication> <authorization> <allow users="sonia"/> <allow users ="soni"/> <deny users="muru"/> </authorization> <compilation debug="true"/> </system.web> </configuration>
FRMLOGIN.aspx
ASP.NET Syntax (Toggle Plain Text)
protected void btnLogin_Click(object sender, EventArgs e) { if (FormsAuthentication .Authenticate(txtUserName .Text ,txtPassword .Text )) { FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, true); Response.Redirect("FrmWelcome.aspx?username=" + txtUserName.Text ); } }
FRMWELCOME.aspx
ASP.NET Syntax (Toggle Plain Text)
protected void Page_Load(object sender, EventArgs e) { lblUserName.Text = Request.QueryString["username"].ToString(); }
Suppose i enter sonia in username & citm123 in password. I will be redirected to FrmWelcome. Suppose now the user copies the URL of FrmWelcome & open in other window,i want that the user is navigated to FrmLogin. How to do it.Using Cookies??? Can somebody help me out!
•
•
Join Date: Jun 2009
Posts: 449
Reputation:
Solved Threads: 82
You are only denying access to the user 'muru'. It means that users other than 'muru' can access the application anonymously.
If you want to prevent the users to access the FrmWelcom or other pages without login to the system, your web.config should be as below
The '?' in deny element prevents anonymous access to the resources.
Also the set the second argument in the statement FormsAuthentication.RedirectFromLoginPage to false.
Setting true will create a durable cookie (one that is saved across browser sessions). Therefore you need to set it as false.
If you want to prevent the users to access the FrmWelcom or other pages without login to the system, your web.config should be as below
ASP.NET Syntax (Toggle Plain Text)
<authorization> <allow users="sonia"/> <allow users="soni"/> <deny users="muru"/> <deny users="?"/> </authorization>
The '?' in deny element prevents anonymous access to the resources.
Also the set the second argument in the statement FormsAuthentication.RedirectFromLoginPage to false.
ASP.NET Syntax (Toggle Plain Text)
FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, false);
Last edited by Ramesh S; Sep 30th, 2009 at 2:17 am.
![]() |
Similar Threads
- Forms Authorization/ Authentication using asp .net and vb .net (ASP.NET)
- Forms Authentication (ASP.NET)
- Website Login (ASP.NET)
- forms authentication in asp.net (ASP.NET)
- Unrecognized configuration section 'forms' (ASP.NET)
- Forms authorization, only want a few links (ASP.NET)
- News Story: ASP.NET Forms Authentication Vulnerability (Upcoming News Stories)
Other Threads in the ASP.NET Forum
- Previous Thread: Running apps in subfolders in Visual Studio with MS SQL
- Next Thread: Hashtable data
| Thread Tools | Search this Thread |
Tag cloud for ASP.NET
.net 2.0 activexcontrol advice ajax alltypeofvideos anathor asp asp.net bc30451 bottomasp.net browser button c# c#gridviewcolumn checkbox click commonfunctions confirmationcodegeneration courier css dataaccesslayer database datagridview datagridviewcheckbox datalist deadlock development dgv dropdownlist edit editing expose feedback flash form formatdecimal forms formview google grid gridview homeedition hosting iframe iis index javascript jquery list listbox login microsoft migration mono mouse mssql multistepregistration news numerical object objects panelmasterpagebuttoncontrols parent problem project radio reportemail richtextbox rotatepage save schoolproject search security session silverlight smartcard software sql-server sqlserver2005 suse textbox tracking unauthorized update validation vb.net video videos view virtualdirectory vista visualstudio web webapplications webdevelopemnt webprogramming webservice xml youareanotmemberofthedebuggerusers





