I need to intercept all the aspx and js file requests and to replace some text labels if they are present. This middleware should work as an IIS module, obviously without interfering with the normal flow of the web application. I wrote some code but I have no idea how to do it.
public partial class Startup
{
public void Configuration(IAppBuilder app)
{
app.Use(typeof(FilterMiddleware), Console.Out);
}
}
public class FilterMiddleware : OwinMiddleware
{
private readonly TextWriter logger;
private readonly OwinMiddleware nextMiddleware;
public FilterMiddleware(OwinMiddleware nextMiddleware, TextWriter logger) : base(nextMiddleware)
{
this.nextMiddleware = nextMiddleware;
this.logger = logger;
}
public override async Task Invoke(IOwinContext context)
{
var headers = context.Request.Headers;
// IF .js OR .ASPX REPLACE TEXT HERE //
await nextMiddleware.Invoke(context);
}
}