Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 825209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:13:08+00:00 2026-05-15T03:13:08+00:00

I am trying to build a webservice that manipulates http requests POST and GET.

  • 0

I am trying to build a webservice that manipulates http requests POST and GET.

Here is a sample:

public class CodebookHttpHandler: IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        if (context.Request.HttpMethod == "POST")
        {
            //DoHttpPostLogic();
        }
        else if (context.Request.HttpMethod == "GET")
        {
            //DoHttpGetLogic();
        }
    }
...

public void DoHttpPostLogic()
{
...
}
public void DoHttpGetLogic()
{
...
}

I need to deploy this but I am struggling how to start. Most online references show making a website, but really, all I want to do is respond when an HttpPost is sent. I don’t know what to put in the website, just want that code to run.

Edit:
I am following this site as its exactly what I’m trying to do.

I have the website set up, I have the code for the handler in a .cs file, i have edited the web.config to add the handler for the file extension I need. Now I am at the step 3 where you tell IIS about this extension and map it to ASP.NET. Also I am using IIS 7 so interface is slightly different than the screenshots. This is the problem I have:

1) Go to website
2) Go to handler mappings
3) Go Add Script Map
4) request path - put the extension I want to handle 
5) Executable-  it seems i am told to set aspnet_isapi.dll here. Maybe this is incorrect?
6) Give name
7) Hit OK button:

Add Script Map

Do you want to allow this ISAPI extension? Click “Yes” to add the extension with an “Allowed” entry to the ISAPI and CGI Restrictions list or to update an existing extension entry to “Allowed” in the ISAPI and CGI Restrictions list.

Yes No Cancel


8) Hit Yes

Add Script Map

The specified module required by this handler is not in the modules list. If you are adding a script map handler mapping, the IsapiModule or the CgiModule must be in the modules list.

OK


edit 2: Have just figured out that that managed handler had something to do with handlers witten in managed code, script map was to help configuring an executable and module mapping to work with http Modules. So I should be using option 1 – Add Managed Handler.

I know what my request path is for the file extension… and I know name (can call it whatever I like), so it must be the Type field I am struggling with. In the applications folder (in IIS) so far I just have the MyHandler.cs and web.config (Of course also a file with the extension I am trying to create the handler for!)

edit3: progress

So now I have the code and the web.config set up I test to see If I can browse to the filename.CustomExtension file:

HTTP Error 404.3 – Not Found
The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.

So in IIS7 I go to Handler Mappings and add it in. See this MSDN example, it is exactly what I am trying to follow

The class looks like this:

using System.Web;

namespace HandlerAttempt2
{
    public class MyHandler : IHttpHandler
    {
        public MyHandler()
        {
            //TODO: Add constructor logic here
        }

        public void ProcessRequest(HttpContext context)
        {
            var objResponse = context.Response;
            objResponse.Write("<html><body><h1>It just worked");
            objResponse.Write("</body></html>");
        }

        public bool IsReusable
        {
            get
            {
                return true;
            }
        }

    }
}

I add the Handler in as follows:

Request path: *.whatever
Type: MyHandler (class name – this appears correct as per example!)
Name: whatever

Try to browse to the custom file again (this is in app pool as Integrated):

HTTP Error 500.21 – Internal Server Error
Handler “whatever” has a bad module “ManagedPipelineHandler” in its module list

Try to browse to the custom file again (this is in app pool as CLASSIC):

HTTP Error 404.17 – Not Found
The requested content appears to be script and will not be served by the static file handler.

Direct Questions

1) Does the website need to be in CLASSIC or INTEGRATED mode? I don’t find any reference of this in the online material, whether it should be either.

2) Do I have to compile the MyHandler.cs to a .dll, or can I just leave it as .cs? Does it need to be in a bin folder, or just anywhere in root?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T03:13:08+00:00Added an answer on May 15, 2026 at 3:13 am

    RE your questions:

    I don’t know the answer to the first one (CLASSIC or INTEGRATED); but I can help with the second…

    Yes you’ll need to compile it first. I have never tried deploying dll’s to anywhere other than the bin, given that that’s the standard I would be suspect in putting them anywhere else even if it did work.

    The way I deploy HttpHandlers is quiet straight forward – all the hard work’s done in web.config, I’v enever had to go into IIS to change any settings.

    For a start, for the http request to be handled by ASP.NET you need to use a request suffix that’s already piped to ASP.NET – like .aspx or ashx. If you want to use something else you will need to config IIS to do this, as per your managed handler img above.

    I tend to use .ashx e.g: http://localhost/foo/my/httphandler/does/this.ashx

    All you need to do (assuming you’ve compiled athe HttpHandler into a DLL and deployed it to the site) is add the necessary config.

    <configuration>
       <system.web>
           <httpHandlers>
                <add verb="*" 
                     path="*.ashx" 
                     type="MyApp.PublishingSystem.HttpHandlers.GroovyHandler, MyApp.PublishingSystem" />
           </httpHandlers>
       </system.web>
    </configuration>
    

    Obviously (?) you can change / restrict the scope using the path, e.g:

    path="*.ashx" 
    path="*ListWidgets.ashx" 
    path="*Admin/ListWidgets.ashx" 
    

    More info here: http://msdn.microsoft.com/en-us/library/ms820032.aspx

    An important gotcha to look out for is the order in which you declare your HttpHandlers in the config; from what I remember ones declared first take precedent. So in this example…

    <add verb="*"  path="*foo.ashx" type="MyApp.PublishingSystem.HttpHandlers.FooHandler, MyApp.PublishingSystem" />
    <add verb="*"  path="*.ashx" type="MyApp.PublishingSystem.HttpHandlers.GroovyHandler, MyApp.PublishingSystem" />
    

    …the groovy handler will handle all HttpRequests except any that end in foo.ashx

    By the way, I make use of HttpHanldrs in my open source .net CMS / app framework, you might find some helpful code there (?): http://morphfolia.codeplex.com/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to build a java ee webservice that has a common base
I am trying to build (csharp) one webservice /WCF engine that make two actions:
I'm trying to build the proxy class for a web service using the wsdl
Trying to build sslsniff on a RHEL 5.2 system here. When compiling sslsniff on
I am trying to build a real-time web service that deals with dynamic 10k
im trying to build an client for an webservice in python with suds. i
I'm trying to build a c# application that displays and invokes all of a
I am trying to build a web service that will stream music over a
I'm trying to build a client jar file to access a webservice. I'm including
I'm trying to build some sort of webservice on google apps. Now the problem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.