ASP. NET Core
ASP. NET MVC 6:https://docs.asp.net/en/latest/mvc/index.html
ASP. core:https://docs.asp.net/en/latest/fundamentals/index.html
Cli-samples:https://github.com/aspnet/cli-samples
Here are some of the lessons I have learned in the process of making this record
Complain!
Microsoft's release Candidate is really a pit-daddy.
1: Starting in early March to see ASP. NET Core, using 2015 to build a test project, all normal OK, can be said to be one step no problem (happy, feel almost Heaven)
2: Unfortunately, this week to update the project to RC2, the project package restore has been the error: "Reference (Error-See" Error List ")" (loss, anger, manic ...) )
3: Looking around, finally getting. NET Cross-platform Journey: Upgrade the sample site from ASP. RC1 to ASP. 1.0, and be overjoyed.
4: Today, after using dotnet Restore to update the package and GG again.
Questions?
The brain is not enough to use Ah, who has more to me two Jin!
After 1:cr2, how do I host a project to IIS or IIS Express?
2: Why I am 2015, I right-click Reference-the Restore package always error "reference (Error-See" Error List ")", but after using dotnet Restore on the command line is normal.
3: Sometimes there will be "no actions matched the current request" error, say what the route has been matched successfully, but the request does not match the action, which is a stem? But after I re-modified the Startup.cs file, it's ready again!
............
N:and so on.
Basic Configuration
Time: March 17, 2016 19:05:03
1, Program entry configuration (Program.cs):
public class program{public static void Main (string[] args) { var host = new Webhostbuilder () . Useserver ("Microsoft.AspNetCore.Server.Kestrel") . Usecontentroot (Directory.GetCurrentDirectory ()) . UseDefaultConfiguration (args) . Useiisplatformhandlerurl () . Usestartup<startup> () . Build (); Host. Run ();} }
Useapplicationbasepath (Directory.GetCurrentDirectory ())
Usecontentroot (Directory.GetCurrentDirectory ())
Anyway, it's unclear why, record it.
2, startup program (Startup.cs):
public class startup{public void Configureservices (iservicecollection services) { services. Addmvc (); Services. Addtransient<model.services.statisticsservice> (); } public void Configure (Iapplicationbuilder app, Ihostingenvironment env, iloggerfactory loggerfactory) { app. Usemiddleware<artifacts. Middlewares.timerecordermiddleware> (); Loggerfactory.addconsole (loglevel.debug); App. Useiisplatformhandler (); App. Useforwardedheaders (New forwardedheadersoptions { forwardedheaders = Forwardedheaders.all }); App. Usestaticfiles (); if (env. Isdevelopment ()) { app. Usedeveloperexceptionpage (); } App. Usemvcwithdefaultroute (); }}
After you have configured the Ingress program and the startup program, dotnet the Restore update package by command, and then type dotnet run to open the self-hosted service.
You can load the page through the default route via http://localhost:5000.
OK, so that's the simple configuration.
Simple process from no-build station
1,win + R type cmd, and then navigate to a directory (my directory is D:\ASP. NET).
D:\asp.net>dotnet newcreated New C # project in D:\ASP.NET.
2, initialize a simple base. NET project by command dotnet New.
D:\asp.net>dotnet restorelog : Restoring packages for d:\asp.net\project.json...info:committing Restore...log : Restore completed in 4200ms. NuGet Config files used: D:\ASP.NET\NuGet.Config C:\Users\Administrator\AppData\Roaming\NuGet\ Nuget.configfeeds used: Https://dotnet.myget.org/F/dotnet-core/api/v3/index.json https://api.nuget.org/ V3/index.json
3. Enter the command to start dotnet Run and start the program.
D:\asp.net>dotnet runcompiling ASP. NET for Dnxcore,version=v5.0compilation succeeded. 0 Warning (s) 0 Error (s) time elapsed 00:00:03.2201958hello world!
4, that's how it works, it's easy to get started.
program file public class program {public static void Main (string[] args) { Console.WriteLine (" Hello world! "); } }
Note: The directory structure is:
d:.│ nuget.config│ program.cs│ project.json│ project.lock.json│├─bin│ └─debug│ └─dnxcore50│ │ ASP. net.dll│ │ ASP. net.pdb│ ││ └─win7-x64│ ASP. Net.deps│ ASP. Net.dll│ ASP. Net.exe│ ASP. net.pdb│ hostpolicy.dll│└─obj └─debug └─dnxcore50 dotnet-compile-csc.rsp Dotnet-compile.assemblyinfo.cs DOTNET-COMPILE.RSP
Because dotnet new creates a console application, there is only one program file.
If you need to build a WEB application, you need to add the Startup.cs file (above) and then use Webhostbuilder to host it in Program.cs.
Category: ASP. NET core Tags: ASP. NET core, ASP 6, ASP. 5
ASP. NET Core