2017-05-05 66 views
0

我试图从MVC控制器会话传递给ASP页面如何从MVC控制器通过传递会话值的ASP页面

public ActionResult RedretToMyAspPage() 
{ 
    var result = MySerive.GetData(stuData); 
    Session["stuDataCode"] = stuData; 
    if (result.Result) 
    { 
     Response.Redirect(result.redirectToURL); 
    } 
    return View(); 
} 

和ASP页上正在逐渐会议

dim studata 
dim len 
len = Len(Session("stuDataCode")) 
studata = Session("stuDataCode") 

但我在这里得到LEN = 0

+1

C#中存在'dim'和'Len'吗?这看起来不像C#代码。 – mmushtaq

+1

@ mmushtaq,nope ..这是传统的VB代码 – Rahul

+0

这是我必须将会话从mvc传递到asp页面的问题 – GaneshV

回答

1

没有,你不能访问session这样既造成您的应用程序(MVC和ASP.NET)可能runni在不同的应用程序池中使用不同的w3wp工作进程。因此会话将不可用。一种解决方案是使用pooled session(或)使用客户端机制cookie(或)将其作为查询字符串参数传递给URL。 localhost:1234/foo?stuDataCode=1234

相关问题