I am using ASP.net 5 Beta 8. I want to make use of Sessions however Context keyword is not being understood.
In my packages.json
"Microsoft.AspNet.Http": "1.0.0-beta8",
"Microsoft.AspNet.Session": "1.0.0-beta8",
In my ConfigureServices of Startup.cs
// Add MVC services to the services container.
services.AddMvc();
//Session Support
services.AddSession();
services.AddCaching();
In Configure of Startup.cs
//Session
app.UseSession();
// Add MVC to the request pipeline.
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
In HomeController.cs
using Microsoft.AspNet.Mvc;
using Microsoft.AspNet.Session;
using Microsoft.AspNet.Http;
public IActionResult Index()
{
Context.Session.SetString("MyString", "test");
return View();
}
And the error I get is
The name 'Context' does not exist in the current context
I also tried removing dnx core from project.json
"frameworks": {
"dnx451": { }
},
but it also doesn't work.
Take note: I have used the previous answers on stackoverflow to try resolve the issue and it hasn't worked. e.g. Link1
I also tried various blog posts on Sessions in ASP.NET 5 but I still get the same error.