Robinsonx6
asked on
URGENT:Problems with session state (asp.net c#)
hi can someone please explain the following and how i get round it please
Server Error in '/www' Application.
--------------------------
Session state is not available in this context.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Session state is not available in this context.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): Session state is not available in this context.]
System.Web.HttpApplication
www.Global.Application_Start(Object sender, EventArgs e)
__________________________
My Global.asax code is as follows
protected void Application_Start(Object sender, EventArgs e)
{
Session.Add("Lang","Englis
}
Hi,
take at this discussion on the same problem ( it is very good ): http://www.dotnet247.com/247reference/msgs/41/206914.aspx
Regards,
B..M
take at this discussion on the same problem ( it is very good ): http://www.dotnet247.com/247reference/msgs/41/206914.aspx
Regards,
B..M
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
hi again AeroSaga
Ok i think im being dumb but i have changed my code as follows:
protected void Application_Start(Object sender, EventArgs e)
{
HttpContext.Current.Sessio n.Add("Lan g","Englis h");
}
but i now get the following error:-
Server Error in '/www' Application.
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceExcept ion: Object reference not set to an instance of an object.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
www.Global.Application_Start(Object sender, EventArgs e)
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
Ok i think im being dumb but i have changed my code as follows:
protected void Application_Start(Object sender, EventArgs e)
{
HttpContext.Current.Sessio
}
but i now get the following error:-
Server Error in '/www' Application.
--------------------------
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceExcept
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
www.Global.Application_Start(Object sender, EventArgs e)
--------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
try putting that statement on the first page_load event of your application such as default.aspx instead.
Aeros
Aeros
This one:
HttpContext.Current.Sessio n.Add("Lan g","Englis h");
HttpContext.Current.Sessio
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok big OOOPPPPSSS i put it in Application start not session start, my mistake thanks eveyone
http://www.visual-basic-data-mining.net/Forums/ISF/shwmessage.aspx?ForumID=17&MessageID=376
Regards,
Aeros