51 lines
1.5 KiB
C#
51 lines
1.5 KiB
C#
// Copyright (c) .NET Foundation. All rights reserved.
|
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
|
|
|
using System.Reflection;
|
|
using ControllersFromServicesClassLibrary;
|
|
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Http.Internal;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace ControllersFromServicesWebSite
|
|
{
|
|
public class Startup
|
|
{
|
|
public void ConfigureServices(IServiceCollection services)
|
|
{
|
|
services
|
|
.AddMvc()
|
|
.AddControllersAsServices(typeof(AnotherController))
|
|
.AddControllersAsServices(new[]
|
|
{
|
|
typeof(TimeScheduleController).GetTypeInfo().Assembly
|
|
});
|
|
|
|
services.AddTransient<QueryValueService>();
|
|
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
|
}
|
|
|
|
public void Configure(IApplicationBuilder app)
|
|
{
|
|
app.UseCultureReplacer();
|
|
|
|
app.UseMvc(routes =>
|
|
{
|
|
routes.MapRoute("default", "{controller}/{action}/{id}");
|
|
});
|
|
}
|
|
|
|
public static void Main(string[] args)
|
|
{
|
|
var host = new WebHostBuilder()
|
|
.UseDefaultConfiguration(args)
|
|
.UseStartup<Startup>()
|
|
.Build();
|
|
|
|
host.Run();
|
|
}
|
|
}
|
|
}
|