VS 2010 web service to set response.statuscode = 500-VBForums
Results 1 to 2 of 2

Thread: web service to set response.statuscode = 500

  1. #1

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    Sitting in an empty room, trying to forget the past
    Posts
    3,396

    web service to set response.statuscode = 500

    I'm writing a web service which my client (as in a person) is going to be calling. If I encounter a situation where I want to report an error condition on the page, he wants me to set Response.StatusCode = 500.

    "On failure, set status code to 500 and pass back the error message. (Respsonse.StatusCode = 500 something along those lines)"

    I don't seem to have a Response object. If I start typing that, intellisense suggests I use HttpResponse, but that doesn't have a StatusCode property.

    Here is my extensive code so far:

    Code:
            [WebMethod]
            public string CheckAllQuantities(List<Document> documents)
            {
                // loop over list for checks
    
               
                return string.Empty;
    
            }
    What "loop over list for checks" means is iterate through the documents he passes me and determine if the user is allowed to order the quantity he has entered. If not, that is when I want to return an error message and set that status code.

    Thanks.
    Last edited by MMock; Nov 15th, 2012 at 11:02 AM. Reason: fixed mistake
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  2. #2

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    Sitting in an empty room, trying to forget the past
    Posts
    3,396

    Re: web service to set response.statuscode = 500

    No one has replied to this. Is it a stupid question? I am taking direction from my customer who is writing the front-end/UI that will call the web service. This is our exchange:

    me:
    Can you explain what your goal is here? On failure, set status code to 500
    him:
    Yes.

    In jQuery, I can simply do the following in the call:

    success: function(data){ //Proceed to checkout;},
    failure: function(errMsg) {
    alert(errMsg);
    // Stop the user from moving forward
    }


    It’s either that, or I have to parse the return. (Just an easy way..)


    Does that make sense?
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.