如题,以前在asp.net mvc的razor中直接在@{ }中使用session或者request就可以了,现在在core中没有,怎么办?
public void ConfigureServices(IServiceCollection services)
{
...
services.AddHttpContextAccessor();
...
}
IHttpContextAccessor
@inject Microsoft.AspNetCore.Http.IHttpContextAccessor _httpContextAccessor
@(_httpContextAccessor.HttpContext.Request.Path)
正解!!!