All pages that are private for members go inside a "UserAdmin" folder - a subfolder of root. In this folder I put a web.config with...
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</configuration>
This will deny anyone who hasn't logged in.
In login.aspx use
System.Web.Security.FormsAuthentication.SetAuthCookie(strTextUsername, False)
strReturnPath = Request.QueryString("ReturnUrl")
If strReturnPath <> "" Then
Response.Redirect(FormsAuthentication.GetRedirectUrl(strTextUsername, False))
Else
Response.Redirect("UserAdmin/index.aspx")
End If
after you've checked the db to see if they entered valid information. If they tried to access a specific page such as /UserAdmin/uploadPics.aspx it will redirect them to that page after they authenticate(log in) which is nice for when people bookmark pages inside that folder.
Plenty of other ways to do this but so far I've found this to be the easiest for me.
0 comments:
Post a Comment