Thursday, May 5, 2011

Custom handler working on Asp.NET Development server but not on IIS 5.1??

Hi guys, ive got a stupid problem.

My Custom handler is working 100% on Asp.NET Development server but when i publish the site to IIS 5.1 whenever i try to run Comment/Find (which finds a user via an AJAX call) (i know the naming of my handler sux!!! :)

I get this error:

The page cannot be displayed The page you are looking for cannot be displayed because the page address is incorrect.

Please try the following:

* If you typed the page address in the Address bar, check that it is entered correctly.
* Open the home page and then look for links to the information you want.

HTTP 405 - Resource not allowed Internet Information Services

Technical Information (for support personnel)

* More information:
  Microsoft Support

My code for the AJAX call is:

 function findUser(skip, take) {

        http.open("post", 'Comment/FindUser', true);
        //make a connection to the server ... specifying that you intend to make a GET request
        //to the server. Specifiy the page name and the URL parameters to send
        http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        http.setRequestHeader('Criteria', document.getElementById('SearchCriteria').value);
        http.setRequestHeader("Skip", skip);
        http.setRequestHeader("Take", take);
        http.setRequestHeader("Connection", "close");

        //display loading gif
        document.getElementById('ctl00_ContentPlaceHolder1_DivUsers').innerHTML = 'Loading, Please Wait...<br /><img src="Images/loading.gif" /><br /><br />';

        //assign a handler for the response
        http.onreadystatechange = function() { findUserAction(); };

        //actually send the request to the server
        http.send(null);

}

Please can anyone help me??

From stackoverflow
  • On IIS not all calls will be processed by the asp.net handler (unlike cassini the development server) unless the call ends in .aspx, .ashx etc. the .NET isapi dll will not process the call.

    The clue is in the

    HTTP 405 - Resource not allowed Internet Information Services

    You will need to also map the handler in the web.config if there is not a corresponding .ashx file in the file system.

  • Make sure you have allowed the extension on the IIS server. The development server does this automatially for you.

    If you open up the properties of the web site then go to the Home Directory Tab and click the configuration button.

    In there try adding the extension you are using for the handler pointing. Set the executable to the aspnet_isapi.dll (look at the standard .aspx extension to find where it is on your computer) and uncheck "Check that file exists".

    I have been burned by this a couple of time and this sorted the problem

    Colin G

    The_Butcher : Hey Colin, thanks a lot for your input!!! However, after unchecking "Check that file exists" I still have the same error. Maybe it has something to do with the fact that I cannot run the CommentHandler.ashx file in IIS it gives the Error the the XML cannot be parsed for CommentHandler.ashx?
    Colin G : @The_Butcher What type of data are you returning eg. json, html, xml? it sounds like there is something wrong with the data more than the service. If you have any code i could look at send it down to pythonandchips at gmail.com
    The_Butcher : thanks man! but i sorted out the problem have a look it was silly. Still think its a bit of a hack though!
  • Thanks for the feedback!!

    Tried both of the suggestions unfortunately they just dont work.....
    adgADGAHADHADHADHADH!!!!! :/

    Knife theKnife = new Knife("jagged_edges");
    Speed theSpeed = new Speed("fast");
    
    slitWrists(theKnife,theSpeed);
    
    //slits wrists according to the given params
    public static void slitWrists(Knife theKnife,Speed theSpeed)
    {
         //NSFW!!!!
    }
    
  • Hey guys I got it!!! The problem was that when i was calling the handler on the dev. server i was calling it liek this

    http.open("post", 'Comment/Rate', true);

    because in my web.config i instructed it to catch all "Comment/" Urls and call the CommentHandler.ashx to handler it.

     <add verb="*" path="Comment/*" type="CoffeeMashup2.CommentHandler"/>
    

    However for some reason in IIS it didnt work so i changed the above call to

    http.open("post", 'CommentHandler.ashx/Rate', true);
    

    and its worked 100%

    thanks a lot guys for your help

0 comments:

Post a Comment