Last active
January 12, 2016 20:41
-
-
Save IEvangelist/950cb27342a2f6bb93de to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Glimpse; | |
using Microsoft.AspNet.Builder; | |
using Microsoft.AspNet.Hosting; | |
using Microsoft.Extensions.Configuration; | |
using Microsoft.Extensions.DependencyInjection; | |
using Microsoft.Extensions.Logging; | |
namespace WebApplication1 | |
{ | |
public class Startup | |
{ | |
// Entry point for the application. | |
public static void Main(string[] args) => WebApplication.Run<Startup>(args); | |
public Startup(IHostingEnvironment env) | |
{ | |
// Set up configuration sources. | |
var builder = new ConfigurationBuilder() | |
.AddJsonFile("appsettings.json") | |
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true); | |
builder.AddEnvironmentVariables(); | |
Configuration = builder.Build(); | |
} | |
public IConfigurationRoot Configuration { get; set; } | |
// This method gets called by the runtime. Use this method to add services to the container. | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddGlimpse(); | |
services.AddMvc(); | |
} | |
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. | |
public void Configure(IApplicationBuilder app, | |
IHostingEnvironment env, | |
ILoggerFactory loggerFactory) | |
{ | |
loggerFactory.AddConsole(Configuration.GetSection("Logging")); | |
loggerFactory.AddDebug(); | |
if (env.IsDevelopment()) | |
{ | |
app.UseBrowserLink(); | |
app.UseDeveloperExceptionPage(); | |
} | |
else | |
{ | |
app.UseExceptionHandler("/Home/Error"); | |
} | |
app.UseIISPlatformHandler(options => | |
options.AuthenticationDescriptions.Clear()); | |
app.UseStaticFiles(); | |
app.UseGlimpse(); | |
app.UseMvc(routes => | |
{ | |
routes.MapRoute("default", | |
"{controller=Home}/{action=Index}/{id?}"); | |
routes.MapRoute("spa-fallback", | |
"{*anything}", | |
new { controller = "Home", action = "Index" }); | |
routes.MapWebApiRoute("defaultApi", | |
"api/{controller}/{id?}"); | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment