0

Hello All,

I am trying to add a clean up code to the global.asax file, when I initially added the code it worked but now its throwing a compilation error for the same. Below is the code which I need to add, I have taken it from Microsoft's website and there its mentioned its valid for .NET 1.1, so I would like to know if anybody can help with the replacement of this for .NET 2.0

<%@ Application  Language="c#" %>
<%@ Import Namespace="ServiceNameSpace" %>
<script runat=server>
protected void Session_Start(object sender, EventArgs e)
{
  //this is needed so we don't generate a new session with each request
  Session["valid"] = true;
}
protected void Session_End(Object sender, EventArgs e)
{
  TempDataStore.Remove(Session.SessionID);
}
protected void Application_End(Object sender, EventArgs e)
{
  TempDataStore.ClearAll();
}
</script>

Edited by __avd: Added [code] tags. For easy readability, always wrap programming code within posts in [code] (code blocks).

2
Contributors
10
Replies
12
Views
7 Years
Discussion Span
Last Post by ggamble
0

I see ... Your going from .Net 1.1 to 2.0 ... sounds like a call has been depreciated.

Can you post the error?

Edited by ggamble: n/a

0

Hello ggamble,

Below are the errors I am getting:

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS0103: The name 'TempDataStore' does not exist in the current context

Source Error:

Line 19:     {Line 20:         //  Code that runs on application shutdownLine 21:         TempDataStore.ClearAll();Line 22: Line 23:     }
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS0103: The name 'TempDataStore' does not exist in the current context

Source Error:

Line 45:         // is set to InProc in the Web.config file. If session mode is set to StateServer Line 46:         // or SQLServer, the event is not raised.Line 47:         TempDataStore.Remove(Session.SessionID);Line 48: Line 49:     }
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS0246: The type or namespace name 'ServiceNameSpace' could not be found (are you missing a using directive or an assembly reference?)

Source Error:

Line 1:  <%@ Application Language="C#" %>Line 2:  <%@ Import Namespace="ServiceNameSpace" %>Line 3:  Line 4:  <script runat="server">

Edited by nikhil257: n/a

0

This may sound extremely silly to you, can you help me with the syntax please?

0

Is this a complied site?
Are you using Visual Studio? If so, what version.
Are the pages using code behind or inline?

0

Its a compiled site, and we are using Visual studio 8. The pages are using .aspx and .cs files.....I

0

Is this a complied site?
Are you using Visual Studio? If so, what version.
Are the pages using code behind or inline?

I was able to import it using <%@ Import Namespace=System.Web.Services %>, but its still not accepting tempdatasore.... :(

0

OK ... in the solution explorer right click on the project or site name. Click 'Add Reference". In the .Net tab, search for the System.Web.Service component then click it and click OK. This will add a new reference to the project. Rebuild and try it out.

Not saying this will work, but it's showing in the error that it's missing the reference, so good luck.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.