在.Net Framework 4.5代码中,使用了System.Web.HttpContext.Current, 在Windows 10中,IIS 10,AspNet5 RC 1,System.Web.HttpContext.Current为空。
答案 0 :(得分:1)
Project.json:
"Microsoft.AspNet.Session": "1.0.0-rc1-final",
"Microsoft.AspNet.Http.Extensions": "1.0.0-rc1-final"
Startup.cs - 配置(..)
app.UseSession();
Startup.cs - ConfigureServices(..)
services.AddCaching();
services.AddSession();
控制器:
@using Microsoft.AspNet.Http;
HttpContext.Session.SetString(“myKey”,“myValue”);
查看:
@using Microsoft.AspNet.Http;
Context.Session.GetString( “的myKey”)