Skip to content

Instantly share code, notes, and snippets.

@pimbrouwers
Created August 27, 2018 18:50
Show Gist options
  • Save pimbrouwers/3128a4e9fcb79e42ff1c6081cae36c0f to your computer and use it in GitHub Desktop.
Save pimbrouwers/3128a4e9fcb79e42ff1c6081cae36c0f to your computer and use it in GitHub Desktop.
.NET Core v2.x Empty Web app
//Views/Shared/_Layout.cshtml
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>@ViewBag.Title</title>
</head>
<body>
@RenderBody()
</body>
</html>
//Controllers/HomeController.cs
using Microsoft.AspNetCore.Mvc;
namespace EmptyWebApp.Controllers
{
public class HomeController : Controller
{
public IActionResult Index()
{
return View();
}
}
}
//Views/Home/Index.cshtml
<h1>Hello world!</h1>
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
namespace EmptyWebApp
{
public class Program
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>();
}
}
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
namespace EmptyWebApp
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseMvcWithDefaultRoute();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment