CustomHeader
using System; | |
using System.Web; | |
namespace CustomHeader | |
{ | |
/// <summary> | |
/// Add Custom Header | |
/// </summary> | |
public class Class1 : IHttpModule | |
{ | |
private HttpApplication App; | |
private string HttpResponseBody; | |
public void Init(HttpApplication context) | |
{ | |
App = context; | |
context.PreSendRequestHeaders += new EventHandler(OnPreSendRequestHeaders); | |
} | |
private void OnPreSendRequestHeaders(object sender, EventArgs e) | |
{ | |
SetProductBanner(); // Add product header | |
} | |
public void SetProductBanner() | |
{ | |
AddHeader("X-Powered-By", AssemblyInformation.Name + "/" + AssemblyInformation.Version); | |
} | |
public class AssemblyInformation | |
{ | |
public static readonly string Name = "CustomHeader"; | |
public static readonly string Release = "Beta"; | |
public static readonly string Version = "1.0.0.0"; | |
} | |
private void AddHeader(string field, string value) | |
{ | |
HttpContext.Current.Response.Headers.Add(field, value); | |
} | |
public void Dispose() | |
{ | |
HttpResponseBody = String.Empty; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment