0
votes

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()));
        }
    }
}
1
@Kirk Woll I edited my post. I'm sure that I do something wrong in IIS configuration.Berke Cagkan Toptas
what if you try without the trailing slash: "localhost/SampleServer.tm"?Kirk Woll
Nothing changed.it gave the same error.Berke Cagkan Toptas
Where do you see that error? And do you see anything interesting in the event log?Kirk Woll
For possible solutions it says that : ASP.Net is not installed or not configured well. And also said that "please be sure that you type the module name correctly". I actually think that there is something wrong with my module names when add handler to IIS.Berke Cagkan Toptas

1 Answers

0
votes

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.