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

  • SEARCH
  • Home
  • 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 8967283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:12:29+00:00 2026-06-15T17:12:29+00:00

I have working WCF REST web service and can set status codes and status

  • 0

I have working WCF REST web service and can set status codes and status descriptions as usual:

OutgoingWebResponseContext response = WebOperationContext.Current.OutgoingResponse;
response.StatusCode = statusCode;
response.StatusDescription = detail.Error;

But I want to use WebFaultException. Unfortunately it alvays return {“Detail”:”Not Found”} when I run my code:

[Serializable]
[DataContract]
public class DtoError
{
    public DtoError()
    {

    }
    public DtoError(string error)
    {
        Error = error;
    }
    [DataMember]
    public string Error { get; private set; }
}

var error = new DtoError(entityName + " is not existing");
throw new WebFaultException<DtoError>(error, HttpStatusCode.NotFound);

Can I return my custom error json object?

  • 1 1 Answer
  • 0 Views
  • 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-06-15T17:12:31+00:00Added an answer on June 15, 2026 at 5:12 pm

    After investigation I found that instead of WebServiceHost we are using WebServiceHost2 from Rest Starter Kit. And inside that host we have to use WebProtocolException. So now my working code looks like that:

    throw new WebProtocolException(HttpStatusCode.NotFound, "Not Found", error, null);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im working on a Web-Application (MyWebApp). I have a Service-Reference to a WCF-Webservice. The
I am working on a WCF REST service, and in the service I have
I have a simple REST web service in WCF that is declared as follows:
I am writing a REST WCF Service, and have it working for connections from
We have working ASP.Net web application with WCF. wcf service hosted as a windows
I have been working on setting up a WCF REST service in .NET 4.0.
I have a working WCF web service. When I run it using F5, I
I am writing a WCF service, (json REST) and I have it working fine
I am using WCF and REST, and I have complex types, which are working
I have a working WCF service. I want to deploy it on Windows Azure.

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.