I am trying to check whether the user is logged in or not in Global.asax as shown in code
but I am getting this error
Error: Object reference not set to an instance of an object.
code:
void Application_BeginRequest(object sender, EventArgs e)
{
if (HttpContext.Current.Request.Url.ToString().Contains("SystemUpload"))
{
if (HttpContext.Current.Session["Login"] == null)
{
Response.Redirect("~/Login.aspx");
}
}
}
could you kindly suggest me how to fix this issue.
thanks in advance
satish
Om prakash SinghPosted Aug 16, 2011, 4:49 AM
satish kumarPosted Aug 16, 2011, 3:46 AM
if he didn't log in then if the url has my folder name (SystemUpload) then he redirects to login page
if (HttpContext.Current.Session["Login"] == null) in this line i am getting the error as
Object reference not set an instance of an object
use new keyword...like this
satish kumarPosted Aug 16, 2011, 3:42 AM
I dont want to do this with authentication, I just wanted to check whether the url has my folder name, if it then the user is redirected to login page.
so that i wanna check whether the user the user is logged in or not...?
could you kindly tell me how to call session object in global.asax page.
thank in advance
satish
Dorababu MekaPosted Aug 16, 2011, 3:37 AM
Priya LingePosted Aug 16, 2011, 3:26 AM
Please see below you will get the solution,
http://stackoverflow.com/questions/1216085/asp-net-2-0-problem-in-httpcontext-current-session-add
http://www.codeproject.com/KB/web-security/formsroleauth.aspx?msg=1980420#xx1980420xx
Hope this will help you.
Thanks.