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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:22:08+00:00 2026-06-04T06:22:08+00:00

I have a service implemented in MVC4 / ASP.NET Web Api. I would like

  • 0

I have a service implemented in MVC4 / ASP.NET Web Api. I would like to return a custom 503 message to my clients when the system is down for maintenance.

I have the following code:

    public class ServiceController : ApiController
    {
        public HttpResponseMessage<ServiceUnavailableModel> Get()
        {
            return new HttpResponseMessage<ServiceUnavailableModel>(new ServiceUnavailableModel(), HttpStatusCode.ServiceUnavailable);
        }
    }

My model looks like this:

    [Serializable]
    public class ServiceUnavailableModel : ISerializable
    {
        public ServiceUnavailableModel()
        {
            this.Message = Resources.SDE_SERVICE_UNAVAILABLE;
            this.Detail = Resources.SDE_SERVICE_REQUESTED_CURRENTLY;
            this.Code = (int)System.Net.HttpStatusCode.ServiceUnavailable;
        }

        public string Message { get; set; }
        public string Detail { get; set; }
        public int Code { get; set; }

        public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            info.AddValue("Message", this.Message);
            info.AddValue("Detail", this.Detail);
            info.AddValue("Code", this.Code);
        }

    }

This is simply what a bunch of my current API clients expect. However, when I execute this action, I get the following result:

HTTP/1.1 503 Service Unavailable
Cache-Control: no-cache
Pragma: no-cache
Content-Type: text/html
Expires: -1
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Mon, 14 May 2012 20:22:39 GMT
Content-Length: 200

The service is unavailable.The service you requested is currently
unavailable or undergoing maintenance. We will have the service back
up and running shortly. Thank you for your patience.","Code":503}

Notice how it appears that my response was partially serialized. What gives?

PS. I’ve tried Response.Clear() and Response.ClearContent() – no luck

  • 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-04T06:22:09+00:00Added an answer on June 4, 2026 at 6:22 am

    It turns out you have to configure http errors to pass through:

    <configuration>
      <system.webServer>
        <httpErrors existingResponse="PassThrough"/>
      </system.webServer>
    <configuration>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom ServiceAuthorizationManager implemented in wcf webhttp service to do api key
I have to use a 3rd party web service implemented in .NET 2.0 (on
I have succesfully implemented a RESTful Web Service using the .NET 4.0 framework with
I have a working SOAP web service implemented with CXF in Java. What would
I have a web service implemented in WCF. This service is only going to
I have a web service, defined(WSDL) and implemented in PHP. This one is relatively
I have implemented a web service with server and client authentication using keytool. The
I have a web service implemented in this folder in this package hierarchy in
I have an android activity and a service implemented using aidl. Works like a
Essentially I have to use a poorly implemented web service maintained by other programmers.

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.