1
votes

Is it possible to set a session in Classic ASP and use it in an MVC project?

I have taken over a project for a company and they have original website in MVC and they the new feature I am adding needs to be in MVC, I am not able to convert the classic ASP to MVC because it would require to much time. So I am looking for a solution where I can set a session in ASP and use it in MVC.

Currently I am setting a session by passing in an ID through a URL to the first MVC page they visit. Which looks like:

<a href="MyMvcPage/1"> MVC Home Page </a>

When I go to the page, I fetch the parameter from the URL and then I create a session, from here I am setting the session in the method "Session_Start()" which is built into MVC. Is there a solution where I can use this method in classic ASP or another method to set a session which I can use in MVC.

1
It's a bit clumsy but the best way I've found of synchronising Classic and .net session variables is to do is with zero size iframes and querystringsJohn
Well right now I am calling a method in .Net and passing in a parameter, but the problem with that is that anyone can call that method and pass in any value they wantuser2836518
msdn offers this solution which looks like it's just writing session variables to a database. msdn.microsoft.com/en-us/library/aa479313.aspx .John
Oh, that looks interesting, looks like a lot of code for something so small but still worth a look at.user2836518
we did it like so: at the Point where you go from classic asp to .net we call a session.asp page. that page stores all the classic asp session variables in a SQL-Server table with a guid. then session.asp Redirects to session.aspx with the guid as a Parameter. then session.aspx reads the session values with the guid from the db and sets them in .net Session object.ulluoink

1 Answers

1
votes

If you don´t want to use a database, go for this approach:

http://devproconnections.com/aspnet/share-session-state-between-asp-and-aspnet-apps (scroll down, you don't have to register)

Because the HttpRequest to your MVC pages also includes the ASPSession in the httpheaders, you can use that one to request an asp page with that same session and return session variables. Actually it's based on session hijacking, but in a good way ;-).