I am new to the IIS module and C# area.
I need to modify the content of static HTML files in a specific directory of a website before the website sends the page content to client. The modification includes adding the banner, footer, etc.
Based on my research, I should be able to achieve my goal through IIS Module (correct?). Here is my code:
namespace MyProject
{
public class MyModule : IHttpModule
{
#region IHttpModule Members
public void Dispose()
{
}
public void Init(HttpApplication context)
{
context.PreSendRequestContent +=
new EventHandler(onPreSendRequestContent);
}
#endregion
public void onPreSendRequestContent(Object source, EventArgs e)
{
HttpApplication app = (HttpApplication)source;
HttpRequest request = app.Context.Request;
HttpResponse response = app.Context.Response;
if (request.Path.Contains("my_specific_directory"))
{
//add banner and footer to the page content
//which class, methods, or properties to use?
}
}
}
}
I am not sure whether PreSendRequestContent is the right event to start modifying page content. Could someone point me to the right way to get page content retrieved by IIS?
Thanks and regards.