public PingerAuthenticationMiddleware(RequestDelegate next) { _next = next; }
public async Task Invoke(HttpContext context) { //break point not hitting here if (context.Request.Method != HttpMethod.Options.ToString()) { var headers = context.Request.Headers; IWorkContext workContext = EngineContext.Current.Resolve<IWorkContext>(); } await _next(context); } }
public void ConfigureServices(IServiceCollection services, IConfiguration configuration) {
}
}
public static class JSONRequestMiddlewareExtensions { /// <summary> /// Configure middleware checking whether requested page is to provide a JSON response /// </summary> /// <param name="application">Builder for configuring an application's request pipeline</param> public static void UseJSONRequestMiddleware(this IApplicationBuilder application) { application.UseMiddleware<JSONRequestMiddleware>(); }
}
public partial class JSONRequestMiddleware { #region Fields
public readonly RequestDelegate _next;
#endregion
#region Ctor
public JSONRequestMiddleware(RequestDelegate next) { _next = next; }
#endregion
#region Methods
public async Task Invoke(HttpContext context) {
object rsp = null;
// Do some stuff
if (rsp == null) { //call the next middleware in the request pipeline await _next(context); }
NopMvcStartup is the last thing to process with Order = 1000 in a standard nopCommerce setup. I guess that MVC is the last thing in to be processed since it servers the content to the client.
So, I'm building a plugin right now, and I put my Order to 900 and things work fine.
using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Nop.Core.Infrastructure; using Nop.Plugin.Misc.VerifyCustomerData.Infrastructure.Extensions;