I'm following this guide and in step 4, I'm asked to add three lines to the project.json file (which I did and then ran dotnet restore getting a lot of updated packages).
When I enter the three lines in the Configure method, I get red lines on all of them. The methods aren't recognized, no intellisense provided etc.
I also noticed that in the example in the guide, the method signature only takes one parameter of IApplicationBuilder, whereas the one I got generated (using the yo aspnet command) looks like this.
Configure(IApplicationBuilder, IHostingEnvironment, ILoggerFactory);
I'm not sure how to resolve it. My guess is that there's a new version of something in the process (Yo, Generators, Core etc.) but I'm not entirely sure.
I've also found this blog where the method signature resembles the one I'm getting. However, the author of it suggest the same syntax that doesn't work for me. I'm guessing it's a matter of referencing the wrong libraries. How do I approach the issue?
Judging from the screenshots in the linked tutorial, its about ASP.NET Core RC1 (back then called ASP.NET 5 r1-final). You can easily recognize this on the package and namespace names.
Microsoft.AspNet.*
is used until rc1.Starting with RC2 the packages were renamed to
Microsoft.AspNetCore.*
to make it clearer its a new framework and not that much compatible with legacy ASP.NET.The
UseIISPlatformHandler()
isn't there anymore, it's nowUseIISIntegration()
within theMain(...)
method:And the packages the package is
Microsoft.AspNetCore.Server.IISIntegration": "1.0.0"
and"Microsoft.AspNetCore.Server.Kestrel": "1.0.1"
. For static files it's:"Microsoft.AspNetCore.StaticFiles": "1.0.0"
.For the
Configure
overload:Configure(IApplicationBuilder);
is default one, but you can add any other type which is registered with the dependency injection system (inConfigureServices
method), as it's a convention system (the startup.cs).That guide is outdated. The updated .Net core does not use project.json anymore which is unfortunate. Instead it is now part of csproj file. And to add the Static file library you have to add it to the project using nuget packet manager. And when you rebuild you will see an entry in csproj file for that library. I think the project.json was a great idea which was inline with core opt-in methodology, since it would allow intellisense to kick in to help you select from available libraries. And since csproj file cant be directly edited in solution you lose that feature.
For Asp.Net core MVC you need to install Nuget package