How to deploy IHttpHandler code to IIS

0

I have a simple handler written in c# with IHttpHandler.How can I make it work on IIS? I followed the tutorial in http://mvolo.com/developing-iis7-modules-and-handlers-with-the-net-framework/#handler but it didn't work for me.

In IIS7 my steps :

  1. I create a new webpage called "SAMPLE"

  2. From HandleMappings I pressed "Add Managed Handler"

  3. I fill the columns -> Request path : *.tm Type : SampleServer.MyHandler Name : MyHandler

  4. Try to open localhost/SampleServer.tm/

I received this error : invalid "ManagedPipelineHandler" module in MyHandler Module List. Error Code : 0x8007000d

Web.сonfig File Generated automatically :

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <handlers>
            <add name="MyHandler" path="*.tm" verb="*" type="SampleServer.MyHandler" resourceType="Unspecified" preCondition="integratedMode" />
        </handlers>
    </system.webServer>
</configuration>

My handler.cs file :

namespace SampleServer
{
    class MyHandler : IHttpHandler
    {
        public bool IsReusable
        {
            get { return false; }
        }

        public void ProcessRequest(HttpContext context)
        {
            DateTime dt = DateTime.Now;
            context.Response.Write(String.Format("<h1>{0}</h1>", dt.ToLongTimeString()));
        }
    }
}
c#
iis-7
ihttphandler
asked on Stack Overflow Nov 2, 2013 by Berke Cagkan Toptas • edited Nov 2, 2013 by abatishchev

1 Answer

0

Finally found the answer. It is because I remove my previous IIS and install IIS7. IIS needs to configuration of .NET library.

Run this command on cmd :

    "%windir%\Microsoft.NET\Framework\"YOUR .NET VERSION"\aspnet_regiis.exe" -i

And then if your website's .NET version is lower than the version of your *.dll file , Change it from the application pool. After that it works well.

answered on Stack Overflow Nov 2, 2013 by Berke Cagkan Toptas • edited Nov 2, 2013 by Berke Cagkan Toptas

User contributions licensed under CC BY-SA 3.0