Working with HttpHandler in IIS 7

link:http://www.dotnetfunda.com/articles/article112.aspx

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, visithttp://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

633528567906905065_SheoNarayan_AddManagedHandelr.jpg

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 !!!

转载于:https://www.cnblogs.com/yboy/archive/2012/01/13/2321527.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值