I have a REST API application made with .NET Core 2.0.
I would like to access the Application
property to store some global settings for all the application.
However, it doesn't seem to be available in any of my controllers
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
namespace EcommerceSynchronizer.Controllers
{
[Route("api/[controller]")]
public class ValuesController : Controller
{
// GET api/values
[HttpGet]
public string Get()
{
HttpContext.Current.Application["key"] = "value";
return "aa";
}
}
}
Resharper complains that
'HttpContext' does not contain a definition for 'Current' and no extension method 'Current' accepting a first argument ...
I tried accessing with HttpContext.Application
but it is not available either.
How can I access HttpApplicationState from a controller ?