aspnetcore/test/WebSites/BasicWebSite/StartupWithDispatching.cs

37 lines
1.1 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 Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
namespace BasicWebSite
{
public class StartupWithDispatching
{
// Set up application services
public void ConfigureServices(IServiceCollection services)
{
services.AddDispatcher();
services.AddMvc()
.SetCompatibilityVersion(CompatibilityVersion.Latest)
.AddXmlDataContractSerializerFormatters();
services.ConfigureBaseWebSiteAuthPolicies();
}
public void Configure(IApplicationBuilder app)
{
app.UseDispatcher();
app.UseMvcWithEndpoint(routes =>
{
routes.MapEndpoint(
"ActionAsMethod",
"{controller}/{action}",
defaults: new { controller = "Home", action = "Index" });
});
}
}
}