HttpHandler not working on hosted IIS 6.0

Last post 10-06-2008 2:40 AM by liga. 11 replies.

Sort Posts:

  • HttpHandler not working on hosted IIS 6.0

    09-15-2008, 3:51 PM
    • Member
      1 point Member
    • MichalN
    • Member since 09-15-2008, 7:45 PM
    • Posts 4

    I have developed in ASP.NET 3.5 small HttpHandler, which is working well from VS 2008. But when I deploy web application to my hoster (IIS 6.0) I receive error 404 - The Page cannot be found. How can I configure web.config for this hosted application to solve this problem?

    It is not possible to set anything on IIS 6.0 as I don't have access to the server.

  • Re: HttpHandler not working on hosted IIS 6.0

    09-15-2008, 4:55 PM
    • All-Star
      21,646 point All-Star
    • gunteman
    • Member since 07-11-2007, 12:57 PM
    • Norrköping, Sweden
    • Posts 3,176

     Is your HttpHandler mapped to anything other than the standard ASP.NET extensions (aspx, asmx etc.)? If so, then you may be out of luck, since the IIS must be configured to pass those requests to the .NET runtime.

    -- "Mark As Answer" if my reply helped you --
  • Re: HttpHandler not working on hosted IIS 6.0

    09-15-2008, 5:30 PM
    • Member
      1 point Member
    • MichalN
    • Member since 09-15-2008, 7:45 PM
    • Posts 4

    Yes. It is mapped to file with no extension...website/products ....

  • Re: HttpHandler not working on hosted IIS 6.0

    09-15-2008, 5:33 PM
    • All-Star
      21,646 point All-Star
    • gunteman
    • Member since 07-11-2007, 12:57 PM
    • Norrköping, Sweden
    • Posts 3,176

     Then I'm afraid you'll have to ask your provider to set the appropriate (wildcard) mappings or change your urls to "website/products.aspx" (still going through the HttpHandler) or similar.

    -- "Mark As Answer" if my reply helped you --
  • Re: HttpHandler not working on hosted IIS 6.0

    09-15-2008, 5:40 PM
    • Member
      1 point Member
    • MichalN
    • Member since 09-15-2008, 7:45 PM
    • Posts 4

    OK. Thanks....

    Using of Application_BeginRequest has similar troubles as HttpHandlers or is it better way?

  • Re: HttpHandler not working on hosted IIS 6.0

    09-16-2008, 7:37 PM
    Answer
    • All-Star
      21,646 point All-Star
    • gunteman
    • Member since 07-11-2007, 12:57 PM
    • Norrköping, Sweden
    • Posts 3,176

     You still won't reach Application_BeginRequest if the IIS is not properly configured.

    -- "Mark As Answer" if my reply helped you --
  • Re: HttpHandler not working on hosted IIS 6.0

    09-17-2008, 3:39 AM
    • Member
      1 point Member
    • MichalN
    • Member since 09-15-2008, 7:45 PM
    • Posts 4

    Thanks!

  • Re: HttpHandler not working on hosted IIS 6.0

    10-02-2008, 9:45 AM
    • Member
      69 point Member
    • liga
    • Member since 11-09-2006, 8:57 AM
    • Posts 141

    Same problem over here.

    The VS integrated development server works just fine. However when I deploy my project to IIS (v6.0, running on the same host) the handler isn't even called.
    Instead the files are directly opened within the browser (which is expected since the HttpHandler isn't called).

     Web.config:

    <add verb="*" path="/download/*" type="My.NameSpace.HttpHandlerDownload" />
     
    The Handler itself: 
    public class HttpHandlerDownload : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            context.Response.Clear();
            string filepath = context.Request.Url.LocalPath;
            string filename = context.Request.Url.Segments[context.Request.Url.Segments.Length - 1];
            context.Response.AddHeader("content-disposition", "attachment; filename=" + filename);
            context.Response.ContentType = ChooseContentTypeHeader(filename);
            try
            {
                context.Response.WriteFile(filepath);
            }
            catch (System.IO.FileNotFoundException fnfex)
            {
                Debug.WriteLine(fnfex.Message);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
            
            context.Response.End();
        }
    
        public bool IsReusable
        {
            get { return false; }
        }
    
        private static string ChooseContentTypeHeader(string filename)
        {
            string[] tmp = filename.Split('.');
            string ext = tmp[tmp.Length - 1];
            switch (ext.ToLower())
            {
                case "pdf":
                    {
                        return "application/pdf";
                        //break;
                    }
                case "txt":
                    {
                        return "text/plain";
                        //break;
                    }
            }
            return null;
        }
    } 
  • Re: HttpHandler not working on hosted IIS 6.0

    10-03-2008, 3:53 PM

    I spent several hours today dealing with this, as it turned out my problem was that  ASP .net was disabled for the whole IIS

    Open IIS Manager

    Web Server Extensions (Bottom)

     ASP.NET v2.0.50727 Prohibited

     

    Change to Allow.   I would think that Microsoft would link the global configuration (Which was prohibiting ASP.NET) to all

    of the sites so when you select Properties, ASP.net it would let you know it was disabled there as well! 

  • Re: HttpHandler not working on hosted IIS 6.0

    10-05-2008, 10:09 AM
    • Member
      69 point Member
    • liga
    • Member since 11-09-2006, 8:57 AM
    • Posts 141

    if ASP wasn't allowed on my IIS I had other problems than a not working http handler trust me :-)

    edit: do I need to touch any IIS settings? Doesn't the web.config do all the magic?

  • Re: HttpHandler not working on hosted IIS 6.0

    10-05-2008, 6:15 PM
    • All-Star
      21,646 point All-Star
    • gunteman
    • Member since 07-11-2007, 12:57 PM
    • Norrköping, Sweden
    • Posts 3,176

     Well web.config does most of the magic, but it won't even be used if IIS is not configured to direct the requests to ASP.NET. In the standard configuration it does that only for .aspx, .asmx etc.

    -- "Mark As Answer" if my reply helped you --
  • Re: HttpHandler not working on hosted IIS 6.0

    10-06-2008, 2:40 AM
    • Member
      69 point Member
    • liga
    • Member since 11-09-2006, 8:57 AM
    • Posts 141

    I see. That makes sense. Thank you.

Page 1 of 1 (12 items)