/// <summary>
 /// Causes the request to be redirected to a page in the default culture when a <see cref="CultureNotFoundException"/> is thrown in the request execution pipeline
 /// </summary>
 /// <param name="next">A task that represents the completion of request processing</param>
 /// <param name="routeCultureOptions">The <see cref="RouteCultureOptions"/> to configure the rerouter with</param>
 /// <param name="logger">An instance of <see cref="ILogger"/></param>
 /// <param name="options">The <see cref="RequestCultureRerouterOptions"/> to configure the middleware with</param>
 public RequestCultureExceptionRerouter(
     RequestDelegate next,
     IOptions <RouteCultureOptions> routeCultureOptions,
     ILogger <LocalizationCookies> logger,
     RequestCultureRerouterOptions options)
 {
     _next = next ?? throw new CultureNotFoundException(nameof(next));
     _routeCultureOptions = routeCultureOptions;
     _logger       = logger;
     _statusCode   = options.StatusCode;
     _responsePath = options.ResponsePath;
 }
Beispiel #2
0
 /// <summary>
 /// Adds middleware that will redirect the user to a page in the default culture whenever a <see cref="System.Globalization.CultureNotFoundException"/> is thrown
 /// </summary>
 /// <remarks>
 /// Use with <see cref="RequestCultureValidation"/> to test for unsupported cultures in the request and handle the exception. Must be placed before UseRequestCultureValidation() in the request execution pipeline.
 /// </remarks>
 /// <param name="builder">The <see cref="IApplicationBuilder"/></param>
 /// <param name="options">The <see cref="RequestCultureRerouterOptions"/> to configure the middleware with</param>
 public static IApplicationBuilder UseRequestCultureExceptionRerouter(
     this IApplicationBuilder builder,
     RequestCultureRerouterOptions options) =>
 builder.UseMiddleware <RequestCultureExceptionRerouter>(options);