views:

665

answers:

5

We have an old web app written in classic ASP. We don't have the resources to rewrite the app.

I know that asp and aspx pages can coexist in the same ASP.NET web app, but it appears as those you cannot share Application and probably Session variables across these two groups of page extension types.

I was hoping to do new development in ASP.NET and to in theory, convert the Classic ASP pages over as we go.

Is there a way to share IIS variables across these two types of web pages (aside from passing information using the query string and forms fields)?

+2  A: 

Not a direct way. You could consider using a shared database backend for your session state.

Mehrdad Afshari
I know that there is a web config option to toggle your asp.net app to use a sql server database to store session state. Do you think that that would work/have any effect on the ASP.NET pages?
Velika
Of course it does affect ASP.NET session state but not classic ASP pages. If you're going to use the ASP.NET's built in SQL Server based session state, you would have to make ASP use that manually.
Mehrdad Afshari
+1  A: 

You could create a simple table in your DB to store the "session" info in. Both the classic asp and the .net pages could read and write there.

Keith
+1  A: 

The only ways to pass this data would be GET/POST values, cookies, flat file, or storing the data to the database. There is nothing "Built In" to the .Net framework to do this.

William Edmondson
+4  A: 

There is no straigthforwad solution for sharing session variables between classic ASP and ASP.NET. I would recommend you to persist sessions into a database, like it is described in this Microsoft Article. This way both ASP and ASP.NET can access session variables.

jdecuyper
+1  A: 

I have seen another solution aside from using the database as shared session holder. I should say beforehand that using the database option is probably much better than this. But...

You can create an ASP page whose only function is to store into and retrieve from the ASP session state. From your ASPX page you can make a webrequest to your ASP page and return any session information in the header, querystring, or even do a scrape of the restulant load. Alternatively you can return an XML stream and make a poor man's web service.

I addition, you could get session state from ASP.NET by doing the opposite and making a .NET page that access session info and returns it.

It's not a good idea and fraught with security problems. I have seen it done is all I'm saying. It's really probably best to rely on the database and possibly pass session ID around.

Chris Cap