Main
method – the entry into your app:WebHostBuilder
. This builder provides methods to allow the host to be configured. In the template app the following configurations are used:.UseStartup<Startup>()
: Specifies the Startup class.UseKestrel
: Specifies the Kestrel server will be used by the appUseContentRoot(Directory.GetCurrentDirectory())
: Uses the web project's root folder as the app's content root when the app is started from this folder.UseIISIntegration()
: Specifies that the app should work with IIS. To use IIS with ASP.NET Core both UseKestrel
and UseIISIntegration
need to be specified.UseStartup()
method on the CreateWebHostBuilder
. It is in this class that you will specify the request handling pipeline, and where you configure any services.ConfigureServices
and Configure
ConfigureServices
method defines the services that will be used by your app.Configure
allows you to compose your request pipeline using Middleware. These are components used within an ASP.NET application pipeline to handle requests and responses. The HTTP pipeline consists of a number of request delegates, called in sequence. Each delegate can choose to either handle the request itself, or pass it to the next delegate.Run
,Map
, and Use
methods on IApplicationBuilder
, but the Run
method will never call a next delegate and should always be used at the end of your pipeline.Configure
method of the pre-built template is built to do a few things. First, it configures an exception handling page for use during development. Then, it sends a response to the requesting web page with a simple 'Hello World'.http://localhost:5000/
, replacing the 5000
with the port that Visual Studio output in the Application Output. You should see the text Hello World!
:Microsoft.AspNetCore.Mvc
dependency to the project by right-clicking the Dependency folder, and selecting Add Package...Microsoft.AspNetCore.Mvc
, and select Add Package. This may take a few minutes to install and you may be prompted to accept various licenses for the required dependencies:app.Run
lambda and set the URL routing logic used by MVC to determine which code it should invoke to the following:app.Run
lambda, as this will override the routing logic./[Controller]/[ActionName]/[Parameters]
HelloWorld
Controller, and the Index
action method.services.AddMvc();
call to the ConfigureServices
method, as illustrated below:http://localhost:xxxx/HelloWorld/Xamarin?name=Amy
(replacing xxxx
with the correct port), you should see the following: