|
Let me know if these basic steps don't get you where you want to be:
Lets say you have a site with 3 aspx pages: Default.aspx, Login.aspx, SuperSecretInfo.aspx. Lets say you want everybody to be able to view Default.aspx without being logged in, you want them to be able to view SuperSecretInfo.aspx only if they are logged in, and you want them to be directed to Login.aspx if they try to access SuperSecretInfo.aspx without being logged in.
You can do the following:
1) Setup web.config like this (chunks of code removed)...
<system.web>
...
<authentication mode= "Forms">
<forms name="MyCookie" loginUrl="Login.aspx" />
</authentication>
...
<authorization>
<deny users="?" />
</authorization>
...
</system.web>
<location path="Default.aspx">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
<location path="Login.aspx">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
2) In Login.aspx code behind (chunks of code removed)...
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnLogin.Click
if GetUserNamePasswordCorrect(username.text,password. text) then
FormsAuthentication.SetAuthCookie(username.text, False)
Response.Redirect("SuperSecretInfo.aspx")
end if
End Sub
Keith
|