Results 1 to 2 of 2

Thread: web service to set response.statuscode = 500

Hybrid View

  1. #1

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    Driving a 2018 Mustang GT down Route 8
    Posts
    4,478

    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 12:02 PM. 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
    Driving a 2018 Mustang GT down Route 8
    Posts
    4,478

    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
  •  



Click Here to Expand Forum to Full Width