This post shows you How to fix 'Session has not been configured for this application or request.'  in ASP.NET or ASP.NET Core MVC.

System.InvalidOperationException: 'Session has not been configured for this application or request.

You encountered the 'Session has not been configured for this application or request.' error because you have not yet declared session.

You need to open the Startup.cs class, then add app.UseSession() before app.UseMvc() in the Configure method.

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    if (env.IsDevelopment())
    {
        app.UseDeveloperExceptionPage();
        app.UseDatabaseErrorPage();
    }
    else
    {
        app.UseExceptionHandler("/Home/Error");
        // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
        app.UseHsts();
    }

    app.UseHttpsRedirection();
    app.UseStaticFiles();
    app.UseCookiePolicy();
    app.UseSession();
    app.UseAuthentication();

    app.UseMvc(routes =>
    {
        routes.MapRoute(
            name: "default",
            template: "{controller=Home}/{action=Index}/{id?}");
    });
}

After add the configuration above you can use

HttpContext.Session["CSharp"]="Value";