Hi,
I am in tutorial Managing Application State. I followed everything it says, yet I couldn't get a working result. In the Startup.cs file function
public void ConfigureServices(IServiceCollection services)
When I added
services.AddCaching();
I got
Error CS1061 'IServiceCollection' does not contain a definition for 'AddCaching' and no extension method 'AddCaching' accepting a first argument of type 'IServiceCollection' could be found (are you missing a using directive or an assembly reference?)
And in function
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
when I added
app.UseSession();
I got
Error CS1061 'IApplicationBuilder' does not contain a definition for 'UseSession' and no extension method 'UseSession' accepting a first argument of type 'IApplicationBuilder' could be found (are you missing a using directive or an assembly reference?)
Here is my reference part in the Startup.cs
using System; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using CanBuy.Data; using CanBuy.Models; using CanBuy.Services;
And here is my project.json file dependency section:
"dependencies": {"Microsoft.NETCore.App": {"version": "1.0.0-rc2-3002702","type": "platform" },"Microsoft.ApplicationInsights.AspNetCore": "1.0.0-rc2-final","Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-rc2-final","Microsoft.AspNetCore.Diagnostics": "1.0.0-rc2-final","Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0-rc2-final","Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0-rc2-final","Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final","Microsoft.AspNetCore.Razor.Tools": {"version": "1.0.0-preview1-final","type": "build" },"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final","Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final","Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-final","Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-final","Microsoft.EntityFrameworkCore.Tools": {"version": "1.0.0-preview1-final","type": "build" },"Microsoft.AspNet.Session": "1.0.0-rc1-final","Microsoft.Extensions.Caching.Memory": "1.0.0-rc2-final","Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final","Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final","Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-rc2-final","Microsoft.Extensions.Logging": "1.0.0-rc2-final","Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final","Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final","Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc2-final","Microsoft.VisualStudio.Web.CodeGeneration.Tools": {"version": "1.0.0-preview1-final","type": "build" },"Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {"version": "1.0.0-preview1-final","type": "build" } },
What could be wrong? Myself didn't do anything except copying/pasting "services.AddCaching();" and "
app.UseSession();". One obvious difference is I am using AspNetCore, while the sample uses AspNet. But I just get them from the template.