The default ASP.NET 5 project template in Visual Studio 2015 Update 3 currently adds Bootstrap 3 to the project. In order to use Bootstrap 4 in your ASP.NET project, you'll need to create an empty ASP.NET project and add the Bootstrap 4 files manually.
To create a project that uses Bootstrap 4, complete the following process:
The previous steps will create a blank ASP.NET Core project. Running the project as-is will only show a simple Hello World output in your browser. In order for it to serve static files and enable MVC, we'll need to complete the following steps:
project.json
file inside the Solution Explorer in Visual Studio.project.json
file:"Microsoft.AspNetCore.Mvc": "1.0.0", "Microsoft.AspNetCore.StaticFiles": "1.0.0"
Startup.cs
file. To enable MVC for the project, change the ConfigureServices
method to the following:public void ConfigureServices(IServiceCollection services) { services.AddMvc(); }
Configure
method to the following code:public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }
When creating an empty ASP.NET Core project, no default controller or views will be created by default. In the previous steps, we've created a default route to the Index action of the Home controller. In order for this to work, we first need to complete the following steps:
Controllers
.Views
.Controllers
folder and select Add | New Item... from the context menu.HomeController.cs
:HomeController
in the Views
folder. Right-click on the Views
folder and select Add | New Folder from the context menu.Home
.Home
folder and select Add | New Item... from the context menu.Index.cshtml
and click on the Add button:3.17.174.204