传统的ASP会话MVC会话 [英] Classic ASP session to MVC session

查看:118
本文介绍了传统的ASP会话MVC会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能在经典的ASP设置会话,并在MVC项目中使用它?

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

我已经采取了一个项目公司,他们有原始网站在MVC和他们的新功能,我将需要在MVC,我不能够在传统的ASP转换为MVC,因为这将需要多少时间。所以我要寻找一个解决方案,我可以在ASP中设置会话和MVC使用它。

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.

目前,我通过传递一个ID通过URL来访问他们的第一个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>

当我去的网页,我取从URL参数,然后我创建一个会话,从这里我在其中内置了MVC方法在session_start()设置会话。是否有一个解决方案,我可以使用传统的ASP或本方法的另一种方法来设置,我可以在MVC中使用会话。

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.

推荐答案

如果您不想将使用一个数据库,去这种方法:

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 (向下滚动,你没有登记)

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

由于该型Htt prequest到你的MVC页面还包括ASPSession在httpheaders,你可以使用一个与同一会话请求ASP页,并返回会话变量。实际上它是基于会话劫持,但在一个好办法 - 。)

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

这篇关于传统的ASP会话MVC会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆