asp.net和MVC3应用程序之间的会话共享 [英] Session sharing between asp.net and MVC3 application

查看:70
本文介绍了asp.net和MVC3应用程序之间的会话共享的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个asp.Net 2.0的应用程序现在有自己的会话管理用于登录目的我想添加一个使用asp.net会话的MVC3应用程序如何实现这个目的?

We have an application which is asp.Net 2.0 It's have it's own session management for Login purpose now I want to add one MVC3 application which use asp.net session how can I achieve this ?

推荐答案

以下链接可能有帮助



^ ]
Below link may help

Sharing sessions across applications using the ASP.NET Session State Service[^]


您可以使用 State Server Sql Server 来存储您的会话,它可以由asp.net和MVC应用程序共享。



状态服务器比Sql Server快一点。
You can use either State Server or Sql Server to store your session, and it can be shared by asp.net and MVC application.

State Server is little faster than Sql Server.


我尝试了一些不同的我不知道它是正确的方式还是没有但我对项目工作感到满意

我的目标是检查会话到期时间。

当我登录到我的ASP.NET 2应用程序时我使用正常存储1个用户名会话变量

折叠|复制代码

I tried some different I don't know it's correct way or not but I am satisfied that project is working
My target was to check session expiry.
when I login to my ASP.NET 2 Application I Store 1 user name using normal Session variable
Collapse | Copy Code
Session["username"] = txtUserName.Text



我把我的MVC3解决方案放在那个网站上

在我的控制器中添加删除更新方法就在那里当你运行MVC应用程序控制器和它的方法被称为

MVC_APP / TestApp / ADD

现在这个网址我的控制器就像是




I put my MVC3 Solution in that website
In my Controllers Add Delete Update methods was there so when you run MVC Application the Controller and it's method get's called
MVC_APP/TestApp/ADD
Now for this url my Controller was like

public ActionResult ADD()
{
// my code
return View();
}





现在我添加了一个额外的参数







Now I added one extra parameter


public ActionResult ADD(string userName)
{
if(StringIsnullOrEmpty(userName))
{
   Redirect("Logout.aspx")
}
else
{
// my code
return View();
}
}





在菜单中点击MVC View

for Eg ADD





In menu click for MVC View
for Eg ADD

Redirect("MVC_APP/testAPP/ADD?userName?="+ Session["userName"])
Redirect("MVC_APP/testAPP/Edit?userName?="+ Session["userName"])





当任何人点击ASP .Net菜单时,会自动查看名为



And when anyone clicks on ASP .Net menu automatically view gets called

这篇关于asp.net和MVC3应用程序之间的会话共享的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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