The last step in creating a Bootstrap 4 enabled ASP.NET MVC project is to create a master layout page that will reference the Bootstrap CSS and JavaScript files. To create the layout page, complete the following steps:
_Layout.cshtml
to the ViewsShared
folder.<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>My Bootstrap Site</title> <link rel="stylesheet" href="~/css/bootstrap.css" /> </head> <body> <div class="container body-content"> @RenderBody() <hr /> <footer> <p>© @DateTime.Now.Year - Your Bootstrap 4 site</p> </footer> </div> </body> </html>
Index.cshtml
to the Views/Home
folder and set its contents to the following:@{ Layout="~/Views/Shared/_Layout.cshtml"; } <h1>This is my Bootstrap 4 site. </h1>
In order to test the site, you'll need to switch back to the command prompt and enter the following command in order to start the Kestrel web server and run your site:
dotnet run
A message will be displayed, stating that the web server is listening on http://localhost:5000
. Open your browser and navigate to the URL. You should see your website running inside the browser with the default Bootstrap 4 styling.
3.139.83.62