<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
</appSettings>
<system.web>
<authentication mode="Forms">
<forms loginUrl="login.aspx" name="authCookie" timeout="60"
path="/">
</forms>
</authentication>
<authorization>
<allow users="?,*" />
</authorization>
</system.web>
<location path="auth.aspx">
<system.web>
<authorization>
<allow users="NewCents" />
<allow roles="admin" />
<deny users="*" />
</authorization>
</system.web>
</location>
</configuration>
here's the page code for getting a security ticket(login.aspx)
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
dim authTicket as System.Web.Security.FormsAuthenticationTicket
authTicket = new System.Web.Security.FormsAuthenticationTicket(1, "NewCents", DateTime.Now, DateTime.Now.AddMinutes(1), false, "admin")dim encryptedTicket as string
encryptedTicket= FormsAuthentication.Encrypt(authTicket)
' Create a cookie and add the encrypted ticket to the cookie as data.
dim authCookie as New System.Web.HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket)
Response.Cookies.Add(authCookie)
Response.Write(encryptedTicket)
end sub
here's the page code for retreiving the ticket (auth.aspx)
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
dim cookieName as string
try
cookieName = System.Web.Security.FormsAuthentication.FormsCookieName
Catch Exc As Exception
'Redirect to login
end try
'Request.Cookiesdim authTicket as System.Web.Security.FormsAuthenticationTicket
tryauthTicket = System.Web.Security.FormsAuthentication.Decrypt(Request.Cookies(cookieName).Value.ToString)
Catch Exc As Exception
'Redirect to login
end try
end sub
I know it's a problem with the web.config file, but I don't understand why it works locally but not on server. I'm using webhost4life if that helps any. I deleted everything in the web.config file except the area that restricts the file auth.aspx and got a login box from webhost4life. I authorize using a SQL database so this isn't going to work. Any suggestions?
TIAsorry, I hadn't set the host virtual directory in control panel. I had no idea this was an option.
0 comments:
Post a Comment