Skip to content
Permalink
f8985fe1bb
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
41 lines (38 sloc) 1.58 KB
// Copyright (c) Martin Costello, 2020. All rights reserved.
// Licensed under the Apache 2.0 license. See the LICENSE file in the project root for full license information.
using System;
using System.ComponentModel;
using Microsoft.AspNetCore.Hosting;
namespace Microsoft.Extensions.DependencyInjection
{
/// <summary>
/// A class containing extension methods for the <see cref="IWebHostBuilder"/> interface. This class cannot be inherited.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public static class IWebHostBuilderExtensions
{
/// <summary>
/// Configures an HTTP GET resource for obtaining valid antiforgery tokens.
/// </summary>
/// <param name="builder">The <see cref="IWebHostBuilder"/> to configure.</param>
/// <returns>
/// The <see cref="IWebHostBuilder"/> specified by <paramref name="builder"/>.
/// </returns>
/// <exception cref="ArgumentNullException">
/// <paramref name="builder"/> is <see langword="null"/>.
/// </exception>
public static IWebHostBuilder ConfigureAntiforgeryTokenResource(this IWebHostBuilder builder)
{
if (builder == null)
{
throw new ArgumentNullException(nameof(builder));
}
return builder.ConfigureServices((services) =>
{
services.AddControllers()
.AddApplicationPart(typeof(TodoApp.AntiforgeryTokenController).Assembly)
.AddControllersAsServices();
});
}
}
}