Go to DotNetFunda.com
 Welcome, Guest!  
LoginLogin  
{ Submit content and get exposure !!! }
Submit: Article | Interview Question | Tips | Joke | Question | Link || Search  
 Skip Navigation Links Home > Articles > Working with HttpHandler in IIS 7

All Articles | Post Articles |  Subscribe to RSS

Working with HttpHandler in IIS 7

 Posted on: 7/28/2008 3:56:22 PM by SheoNarayan | Views: 819 | Category: ASP.NET | Level: Intermediate | Print Article
ASP.NET Hosting with Windows 2008/2003
In order to use custom HttpHandler in IIS 6 we simply used to write <httpHandlers> tag inside System.web tag in web.config file but in IIS 7 it is little tricky. In this article, I am going to show how to configure custom HttpHanlder in IIS 7.


Introduction

If you had used Custom HttpHandler in your application that was hosted on IIS 6 or on Windows XP system and have shifted to IIS 7 or Vista now, your HttpHanlder will not work. You will have to do a little trick in your web.config file either manually or through IIS 7. (To know more about how to write Custom HttpHanlder to form SEO friendly url, visit http://www.dotnetfunda.com/articles/article75.aspx )

 

Configuring Custom HttpHanlder in IIS 7

There are two ways you can configure your Custom HttpHandler in IIS 7.

First way

The first way is by going through Wizard in IIS. Lets see how to do that.

  1. First open your IIS 7.
  2. Got to your website
  3. Open Handler Mappings by double clicking it.
  4. Click Add Managed Handlers ... from Action pane (right side), you should see your screen something like Picture - 1 below.
  5. Write Request Path
  6. Write Type of the handler you want to use for the requested path
  7. Write Name of this handler for identification purpose.
  8. Click OK

Picture - 1

 


As soon as you will click OK, you can notice that your application web.config file has been changed. In my case my code inside web.config file looks like following

<system.webServer>

<handlers>

<add name="MyCustomHanlder" path="/mypage/mypage*.aspx" verb="*" type="MyHanlder.CustomHttpHanlder" resourceType="Unspecified" preCondition="integratedMode" />

</handlers>

<system.webServer>

Notice that earlier we used to write handlers inside <system.web> > <httpHandlers> but here it is written in <system.webServer> > <handlers>. Once your web.config file has been modified, you are done. Now simply test it. Try any url like http://localhost/mypage/mypageWHATEVER.aspx (in my case) and you will see that your hanlder is working now.

Second way

The second way is very easy, simply copy the code of the hanlder you just added and modify their corresponding attributes and place inside <handlers> and it will work. So there is no need to go to IIS every time to add new handlers.

Hope you liked this small but useful article.

Thanks and keep reading !!!


Interesting?  Bookmark and Share kick it on DotNetKicks.com


About Sheo Narayan

Experience:6 year(s)
Home page:http://sheonarayan.myfunda.net/
Member since:Tuesday, July 08, 2008
Biography:Throughout 1st in all educational exams.
Major qualifications: HDCS, ADCA, MCA, MCTS
Location: Hyderabad, India
 Latest post(s) from SheoNarayan

   ◘ Classes in C# posted on 11/18/2008 7:44:13 PM
   ◘ Iterative Statements in C# (Loops in C#) posted on 11/17/2008 10:19:03 AM
   ◘ Nullable type in C# posted on 11/14/2008 10:10:43 PM
   ◘ Premitives (Data Types) in C# posted on 11/14/2008 9:47:29 PM
   ◘ Verbatim Character in C# posted on 11/14/2008 9:00:27 PM




About Us | Contact Us | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
All rights reserved to DotNetFunda.com. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks.
(Best viewed in IE 6.0+ or Firefox 2.0+ at 1024 * 768 or higher)