I'm trying to create a custom login on a custom database. The database itself has username & password (name, address, ect). Now my problem is authorization. When I put in web.config <authorization></authorization>
and run the program It won't load the masterpage design. So what's my alternative for authorization? And found some code for global.asax (for session):
void Application_OnPostRequestHandlerExecute()
{
CheckLogin();
}
void CheckLogin()
{
string Url = Request.RawUrl;
int count = Url.Length - 10;
string TestUrl = Url.Substring(count);
string SessionData = Session["Authenticate"].ToString();
if (SessionData == "" && TestUrl != "Home.aspx")
{
Response.Redirect("~/Home.aspx");
}
}
Can someone explain it a little? I mean the testUrl
, why is the couter there (url.lenght-10)?
Do you mean Authentication or Authorization? These are different concepts.
The function you provided, just checks in a very strange way whether the page requested is the homepage or that the Session variable "Authenticate" is empty.
Are you using ASP.NET MVC? or plain ASP.NET?
I recommend you do a search on Google on the topic "Custom FormsAuthentication ASP.NET"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.