text
stringlengths 0
13.4k
|
|---|
Now listening on: http://localhost:5000
|
Application started. Press Ctrl+C to shut down.
|
Instead of printing to the console and exiting, this program starts a web
|
server and waits for requests on port 5000.
|
Open your web browser and navigate to http://localhost:5000 . You'll
|
see the default ASP.NET Core splash page, which means your project is
|
working! When you're done, press Ctrl-C in the terminal window to stop
|
the server.
|
The parts of an ASP.NET Core project
|
The dotnet new mvc template generates a number of files and
|
directories for you. Here are the most important things you get out of
|
the box:
|
The Program.cs and Startup.cs files set up the web server and
|
ASP.NET Core pipeline. The Startup class is where you can add
|
middleware that handles and modifies incoming requests, and serves
|
things like static content or error pages. It's also where you add your
|
own services to the dependency injection container (more on this
|
later).
|
The Models, Views, and Controllers directories contain the
|
components of the Model-View-Controller (MVC) architecture.
|
You'll explore all three in the next chapter.
|
16
|
Create an ASP.NET Core project
|
The wwwroot directory contains static assets like CSS, JavaScript,
|
and image files. Files in wwwroot will be served as static content,
|
and can be bundled and minified automatically.
|
The appsettings.json file contains configuration settings ASP.NET
|
Core will load on startup. You can use this to store database
|
connection strings or other things that you don't want to hard-code.
|
Tips for Visual Studio Code
|
If you're using Visual Studio Code for the first time, here are a couple of
|
helpful tips to get you started:
|
Open the project root folder: In Visual Studio Code, choose File -
|
Open or File - Open Folder. Open the AspNetCoreTodo folder (the
|
root directory), not the inner project directory. If Visual Studio Code
|
prompts you to install missing files, click Yes to add them.
|
F5 to run (and debug breakpoints): With your project open, press F5
|
to run the project in debug mode. This is the same as dotnet run
|
on the command line, but you have the benefit of setting
|
breakpoints in your code by clicking on the left margin:
|
Lightbulb to fix problems: If your code contains red squiggles
|
(compiler errors), put your cursor on the code that's red and look for
|
the lightbulb icon on the left margin. The lightbulb menu will suggest
|
17
|
Create an ASP.NET Core project
|
common fixes, like adding a missing using statement to your code:
|
Compile quickly: Use the shortcut Command-Shift-B or Control-
|
Shift-B to run the Build task, which does the same thing as dotnet
|
build .
|
These tips apply to Visual Studio (not Code) on Windows too. If
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.