How to create HTTP pipeline in ASP.net 3.5?


In ASP.net, you can do server-side HTTP programming which is highly flexible and easy to customized. Global.asax only runs with ASP.NET files which are served from IIS and those do not go through Begin_Request in ASP.NET. I hope this article will be useful for all .Net users.

Description - Single TCP connection can be used to send multiple HTTP requests. There is no waiting period for the corresponding responses.
Client as well as the server are required to support the same.
Steps -
1)
I have added following code in Global.asax


public void Application_BeginRequest(object sender, EventArgs e)
{
Context.Items["start time"] = DateTime.Now;

}
public void Application_EndRequest(object sender, EventArgs e)
{
DateTime dt = (DateTime)Context.Items["start time"];
//It is used to calculate the difference.
TimeSpan delta = DateTime.Now - dt;
//It will generate the output as time difference.
Response.Write ("<h5>" + delta + "</h5>");
}

2) I have added two .aspx pages and in one of these page, in Page_Load, I have added following code for getting delay response.

protected void Page_Load(object sender, EventArgs e)
{
Thread.Sleep(2000);
}

You can set one page as "start up page" and view the output then set second .aspx page as "start up page" and see the output and then compare.
This will indicate an HttpApplication and its modules, handler will only be used to process one request at a time. You can implement your own HTTP modules, handlers, and handler factories with the help of ASP.NET HTTP pipeline. HttpApplication class behaviour can also be extended as per the requirements. ASP.NET HTTP pipeline treats each virtual directory as an application. HTTP handlers are always treated as the endpoints for communication. IHttpHandler interface can be implemented with the help of HTTP Handlers.


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: