rahul shinde

rahul shinde

  • NA
  • 20
  • 0

how to use Http handler and module

Nov 12 2013 9:36 AM
I want to Redirect from application one hosted on one server to another application hosted on another server.When I redirect to 2nd server at that time how I get information of Get Request From which sever it comes.

I tried following module code.
public class NewModule:IHttpModule
{

private const string OriginalUrlKey = "CharlieFriendlyUrlModuleRecordOriginalUrl";

 
//// Record the original, friendly URL. This value is used later in the Pipeline.
private void BeginRequest(object sender, EventArgs e)
{
HttpContext context = ((HttpApplication)sender).Context;

 
string originalUrl = string.Empty; // code to get original URL from HttpContext.Current.Request
originalUrl = context.Items[OriginalUrlKey].ToString();
}

 

private HttpApplication _application = null;
string path, schme, applicationpath;
public void Dispose()
{
}

public void Init(System.Web.HttpApplication context)
{
// save the context
_application = context;
 
// handle the end request
context.EndRequest += new EventHandler(context_EndRequest);
}

 
// tag a message at the end of the page
void context_EndRequest(object sender, EventArgs e)
{
string message = string.Format("Generated at {0}",
System.DateTime.Now.ToString());
// stream it at the end of the response
_application.Context.Response.Write(message);
}
}