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>

What is TempDataStore?

I am not sure about what exactly it is, I just copied it from Microsoft's website and it worked for me for a few days then it stopped working. I got that from this link http://msdn.microsoft.com/en-us/library/ms979200.aspx#scalenethowto08_topic11 may be you can get some idea about it.

I am actually not a developer, I was searching for a solution for a problem we are getting on our site, and then stumbled up on this link.

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

Can you post the error?

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">

Try adding a reference to System.Web.Services

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

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

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

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.... :(

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.