魔物公寓
45.13M · 2026-03-13
public void ConfigureServices(IServiceCollection ServiceCollection)
{
ServiceCollection.AddMvc();
}
四 注册MVC中间件,并配置路由规则
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseMvc((RouteBuilder) => { RouteBuilder.MapRoute("default", "{Controller}/{Action}/{Parameter}", new { @Controller = "Home", @Action = "Index", @Parameter = String.Empty }); });
}
五 创建控制器Home与Index视图六 运行项目 ok