using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
namespace PocoDemo
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
//自定义视图位置格式
services.AddMvc().AddRazorOptions(options =>
{
options.ViewLocationFormats.Clear();
options.ViewLocationFormats.Add("/Views/{1}/{0},cshtml");
options.ViewLocationFormats.Add("/Views/Shared/{0},cshtml");
options.ViewLocationFormats.Add("/Views/Shared/Layouts/{0},cshtml");
options.ViewLocationFormats.Add("/Views/Shared/PartialViews/{0},cshtml");
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
//app.UseMvcWithDefaultRoute();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "demo",
template: "go/to/{city}/for/{days}/days",
defaults: new { controller="Input",action="Go"
});
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
app.Run(async (context) =>
{
await context.Response.WriteAsync("Hello World!");
});
}
}
}