Using ASP.NET in a Content

By default, ASP.NET does not allow applications to be accessed remotely. This means that the in-project web browser will not be able to access the application, as it is technically running outside of the sandbox environment.
To address this, add a UseUrls statement, as shown below:
public static IWebHost BuildWebHost(string[] args) =>
Some projects use a different port such as 5001. Replace 5000 with the port your application uses everywhere that 5000 is used in this guide.
If your application includes any forms, you will need to add the following line of code in the Startup.cs class's ConfigureServices method before calling AddRazorPages or AddMvc:
services.AddAntiforgery(o => o.SuppressXFrameOptionsHeader = true);
Without this line, anytime an Antiforgery token is generated (most forms generate this token) the X-Frame-Options header is automatically added, which can cause "connection refused" errors in the Web Browser tab.
Set the applicationURL to "" in Properties\Launchsettings.json.

Content Settings

To get the ASP.NET Core app to work, you’ll need to change a few settings. Under Tabs Enabled, check “Enable Web Browser”.
With that done, go to the now visible Web Browser Settings. There, change the Starting Browser URL to {{localhost:5000}}.
Under Settings, add the following in the startup script to enable SQL Server:
sudo systemctl enable mssql-server
sudo systemctl start mssql-server

EF Core and database generation

Change the connection string in your application as follows. Of course, the database name you can choose yourself:
"ConnectionStrings": {
"DefaultConnection": "Server=.;Database=BethanysPieShop;User Id=sa;Password=P@ssword1"
If you are using Entity Framework Core and want to use scaffolding to restore your database, you should first now install the EF Core tools by running the following command in a Terminal tab:
dotnet tool install --global dotnet-ef
Now, navigate to the folder where your .csproj lives and there, run:
dotnet build
After successful build, run the following to restore your database:
dotnet ef database update
Your migrations will now be executed while generating the database.

Running the Application

You can then use dotnet run to start your application. Open a browser tab and navigate to http://localhost:5000. You should now see your site!
Tip: Projects run on Linux so folder/file paths are case sensitive. Therefore “contents/site.css” is not the same as “Contents/site.css”!