In this video, learn how to run ASP.NET applications from Visual Studio and the command line.
- [Narrator] When running and debugging ASP.NET Core applications, you now have additional options over what you had with non dot net core. You can run in Visual Studio using a combination of IIS Express and Kestrel or Kestrel by itself. You can also run outside of Visual Studio from a command prompt by simply typing dotnet run as long as you're at the same directory level as the CS proj file.
When running in debug mode, the profiles are configured through a file named launchSettings.json. This can either be edited directly in the json or to the project properties. Running an IIS simulates a deployment to a Windows server. Using both IIS and Kestrel and tying them together with a reverse proxy. Running in Kestrel is useful for development purposes because of all the extra logging that gets ouput into the console window.
Now let's go look at this in Visual Studio. The launch settings json file in an ASP.net core project is found under the properties node and in it you'll see several json objects starting with IIS settings that has the application URL in the sslPort and down to the profiles that are available through the run command in Visual Studio. Here on line eleven we have IIS Express which will launch a browser going to the application URL specified on line six and sets the environment to development.
The Kestrel profile is by default named after the project name and has the same settings in it with the addition of the application URL. These settings are also available in the project properties and if you go to the debug tab, here you see the SpyStore v ten which is the Kestrel profile in the IIS Express. To run from within Visual Studio, you can select a profile in the drop-down by the run command and you can see the IIS Express profile as well as the Kestrel profile.
Merely switching to the other profile and clicking run will start the application. In this case it would start using Kestrel. To run from the command line, make sure you're in the same directory as the CS proj for your project and we can check to make sure that we are and right here we have the SpyStore version one point o csproj file and we merely type in dotnet run and after a few seconds, we will see a warning 'cause we're using one one nine, ignore that for now, but here it says, "now listening on port 5000" and "the application has started, use control c to shut down." So those are the three ways that you can run ASP.net Core applications.
- Running and debugging ASP.NET Core applications
- Pros and cons of migrating existing applications to ASP.NET Core.
- Built-in dependency injection
- Environment awareness and app configuration
- Web host configuration and SSL
- View components invoked as tag helpers
- Configuration and logging
- Using Razor Pages
- Web API improvements
- Support for creating GDPR-compliant applications