Classic .ASP and .NET.aspx web pages in one ASP.NET web application.

We have an old web application written in classic ASP. We have no resources to rewrite the application.

I know that asp and aspx pages can coexist in the same ASP.NET web application, but they appear as those with which you cannot share applications and, possibly, with session variables in these two groups of page extension types.

I was hoping to do a new development in ASP.NET and theoretically convert ASP pages to the classic format.

Is there a way to share IIS variables in these two types of web pages (other than passing information using the query string and forms)?

+7
asp-classic
source share
7 answers

There is no straigthforwad solution for sharing session variables between classic ASP and ASP.NET. I would recommend that you continue sessions in the database as described in this Microsoft Article . In this way, ASP and ASP.NET can access session variables.

+9
source share

Not a direct path. You might consider using the backend of a shared database for session state.

+2
source share

You can create a simple table in your database to store information about the "session". Both classic asp and .net pages could read and write there.

+1
source share

The only ways to transfer this data will be GET / POST values, cookies, a flat file, or storing data in a database. There is nothing "built-in" in the .Net framework for this.

+1
source share

I saw another solution besides using the database as the general owner of the session. I have to say in advance that using the database option is probably much better than that. But...

You can create an ASP page whose sole function is to save and retrieve ASP session state. On an ASPX page, you can make a web request to your ASP page and return session information in the header, request, or even clear the restart load. Alternatively, you can return the XML stream and make the poor web service.

In addition, you can get session state from ASP.NET by doing the opposite and creating a .NET page that will access the session information and return it.

This is not a good idea and is fraught with security problems. I saw that this is all I say. It is probably best to rely on the database and possibly pass in the session identifier.

+1
source share

Well, I just ran into this problem and want to tell you that I was just able to solve it in one way. The solution was relatively simple and actually depends on your initial development, in my case, the system flow requires logging in to the default.aspx page and after the user / password is checked correctly, the Init.asp page is executed and that is where a lot of session vars are created and loaded ( this is actually the minimum size), after which the last command redirects the user to mainmenu.aspx and forms this page, which we call .aspx and .asp.

This solution worked for me only because of the choices made by the original developer when developing this ASP 3.0 application, and, as you can imagine, I cannot get these values ​​on asp.net pages.

+1
source share

I just went through this. My solution was to wrap it all up in a nodejs application. I am extracting JWT tokens from a .NET web API that have all user requirements encoded in a payload. This token is stored in a cookie on the client. A cookie will be automatically sent for each request to your domain, so all you need to do is read the cookie value from the header and decode the payload (in ASP.NET and Classic ASP yourself). After you read the contents, you can simply set the session variables according to those that were built into the JWT token.

I prefer this method because it has 0 database synchronization and moves your application to OAuth2 openid and from the session.

0
source share

All Articles