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 556897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:58:07+00:00 2026-05-13T11:58:07+00:00

Im calling a WCF service from jquery ajax. Sometimes the service throw some custom

  • 0

Im calling a WCF service from jquery ajax. Sometimes the service throw some custom errors and when it does I need to get the message of that error. In the error function of my ajax call I have the following code:

            error: function(data) {
              alert("responseText: " + data.responseText);
            }

And the responseText when the error is thrown looks something like:

responseText: {"ExceptionDetail":{"HelpLink":null,"InnerException":null,"Message":"Denied",......}}

I want to get the “Message” from “ExceptionDetail” but I’m not sure how to do it.

My WCF service looks like this, to test it I just throw an error:

[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Json)]
public string myFunction(string id)
{
    throw new Exception("Denied");
}

How can I get the Message of the error?

  • 1 1 Answer
  • 1 View
  • 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-13T11:58:07+00:00Added an answer on May 13, 2026 at 11:58 am

    By default, WCF will not return any exception details – that is a wanted feature, by design, in order not to divulge too much information back to a possible attacker.

    If you want to enable detailed exception messages, you can do this by enabling a behavior on the server side:

     <system.serviceModel>
        <behaviors>
          <serviceBehaviors>
            <behavior name="debugBehavior">
              <serviceDebug includeExceptionDetailInFaults="True" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
    
        <services>
            <service name="YourService"
                     behaviorConfiguration="debugBehavior">
                 .....
            </service>
        </services>
    

    But even now – you need to be aware that WCF should be interoperable, thus a client might not be running on .NET –> therefore you cannot just simply throw back an exception – that’s a .NET specific construct.

    Your best option is to catch all exceptions on the server (using e.g. the IErrorHandler interface), and turning those into SOAP faults – the interoperable equivalent of a .NET exception. If you know that the other end is a .NET client at all times, you can easily convert a .NET exception into a FaultException<T> where T is your .NET exception.

    When you do this, you can catch an exception on the client by trapping the FaultException<T>, and its .Detail property should contain the normal .NET exception as you know it (and that contains a .Message property with the exception message).

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

Sidebar

Related Questions

Does anyone have any good examples of calling a WCF service from a classic
I am calling a WCF service from some stub. The issue is that, I
When calling a WCF service from a console app, asp.net app, wpf/winform app, you
Hi All I am currently having an issue calling a WCF service from a
I am calling a non-WCF service from a WCF client. The WCF client includes
I'm calling a WCF service from a Silverlight client, therefore making all the calls
I am calling a WCF service from a WCF proxy(client) withing another WCF service
When calling a WCF web service from a C# client (instance of System.ServiceModel.ClientBase<>) how
When calling a WCF service from Silverlight that works for smaller parameters, but fails
Will calling close on my WCF service kill all resources or set them up

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.