Classic ASP session to MVC session

佐手、 提交于 2019-12-08 04:17:55

问题


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:


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 ;-).



来源:https://stackoverflow.com/questions/25413058/classic-asp-session-to-mvc-session

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!