Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the performance difference between HttpModule and Global.aspx?

I have made a web app where I am using a module which redirects without "www" urls (http://example.com/) to with "www" urls (http://www.example.com/). But as I am on shared hosting server, where I don't have permission to implement a HttpModule, then I tried the same module code with Global.asax file. That works!

I used the following (Application_BeginRequest()) event to implement my HttpModule functionality.

void Application_BeginRequest()
{
  //module code
}

The module and application is working well and correctly from Global.asax file But I am worried about the performance.

Why we use the HTTPModules in asp.net If we can implement the same using Global.asax file. Is there ay performance differences between both. Or any difference about which I need to worry about when using Global.asax file instead of HttpModule ??

Please explain!

like image 808
djmzfKnm Avatar asked Feb 21 '09 15:02

djmzfKnm


People also ask

What is the difference between httpmodule and global Asax?

Now most of what you can do with an httpModule can be done in the Global.asax file. The main difference between the two is that common functionality can be encapsulated in an httpModule and distributed among various sites and even placed in the GAC. The advantage the Global.asax has is that it is easier to work with Session level events.

What is the difference between httpmodule and httphandler?

The quick answer is httpModule works with the web application as sort of an adjunct to the request pipeline because modules generally add some processing in response to an event in the pipeline. An httpHandler actually processes the request type and renders the output being sent to...

What is the difference between httpclient and httpmodule in angular?

They both support HTTP calls but HTTP is the older API and will eventually be deprecated. The new HttpClient service is included in the HttpClientModule that used to initiate HTTP request and responses in angular apps. The HttpClientModule is a replacement of HttpModule.

What are HTTP modules used for?

HTTP Modules are plugged into the life cycle of a request. So when a request is processed it is passed through all the modules in the pipeline of the request. So generally http modules are used for:


1 Answers

Global.asax inherits from HTTPApplication, and HTTPModules must implement the IHTTPInterface.
The HTTPModules Init method gets the HTTPApplication object passed in.
In the Init method you can hook into the events of HTTPApplication.

I would recommend to use HTTPModules wherever you can.
Especially if you make shrink-wrapped software where the customer can replace your global.asax with their own.

like image 61
Kb. Avatar answered Sep 22 '22 18:09

Kb.