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

Priya LingeRank #785 · 2.9K reputationPosted Aug 15, 2011, 11:26 PM EDT
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.
Dorababu MekaRank #457 · 5.5K reputationPosted Aug 15, 2011, 11:37 PM EDT
satish kumar9 reputationPosted Aug 15, 2011, 11:42 PM EDT
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
satish kumar9 reputationPosted Aug 15, 2011, 11:46 PM EDT
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
Om prakash Singh126 reputationPosted Aug 16, 2011, 12:49 AM EDT