Once you've installed, open a new command prompt and run the following command:
Once you've installed, open a new terminal and run the following command:
Command prompt
dotnet
If the installation succeeded, you should see an output similar to the following:
Command prompt
Usage: dotnet [options]Usage: dotnet [path-to-application]Options:-h|--help Display help.--info Display .NET information.--list-sdks Display the installed SDKs.--list-runtimes Display the installed runtimes.path-to-application:The path to an application .dll file to execute.
Got an error?
If you receive a 'dotnet' is not recognized as an internal or external command error, make sure you opened a new command prompt. If you can't resolve the issue, use the I ran into an issue button to get help fixing the problem.
Create your app
In your command prompt, run the following command to create your app:
In your terminal, run the following command to create your app:
Command prompt
dotnet new webApp -o myWebApp --no-https
Then, navigate to the new directory created by the previous command:
Command prompt
cd myWebApp
What do these commands mean?
The dotnet new command creates a new application.
The webApp parameter selects what template to use when creating your app.
The -o parameter creates a directory named myWebApp where your app is stored.
The --no-https flag specifies not to enable HTTPS.
The cd myWebApp command puts you into the newly created app directory.
What files were created?
Several files were created in the myWebApp directory to give you a simple web application that is ready to run.
Startup.cs contains the app startup code and middleware configuration.
The myWebApp/Pages directory contains some example web pages for the application.
myWebApp.csproj defines what libraries are referenced etc.
Got an error?
If you receive a message similar to Template "ASP.NET Core Web App" could not be created. Access to the path 'C:\Windows\System32\myWebApp' is denied, change your current directory to one where you have permissions to create a new folder and try to run the command again. If you can't resolve the issue, use the I ran into an issue button to get help fixing the problem.
Run your app
In your command prompt, run the following command:
In your terminal, run the following command:
Command prompt
dotnet watch run
The dotnet watch run command will build and start the app, and then rebuild and restart the app whenever you make code changes. You can stop the app at any time by selecting Ctrl+C.
Wait for the app to display that it's listening on http://localhost:5000 and for the browser to launch at that address.
Wait for the app to display that it's listening on http://localhost:5000 and then open a browser and navigate to that address.
Congratulations, you've built and run your first .NET web app!
Edit your code
Open Pages/Index.cshtml in any text editor and replace all of the code with the following, then save the file.
Index.cshtml
@page@model IndexModel@{ ViewData["Title"] = "Home page";}<div class="text-center"> <h1>Hello, world!</h1> <p>The time on the server is @DateTime.Now</p></div>
Once this change is saved, the dotnet watch run command will restart the app and refresh it in the browser so you can see the change in the running app.
Once this change is saved, the dotnet watch run command will restart the app. Refresh the app in the browser to see the change in the running app.
Next steps
Now that you've got the basics, continue building your first ASP.NET app with Razor Pages.