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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:00:53+00:00 2026-06-08T02:00:53+00:00

i am trying to write out a response to the client: response.StatusCode = (int)HttpStatusCode.BadRequest;

  • 0

i am trying to write out a response to the client:

response.StatusCode = (int)HttpStatusCode.BadRequest;
response.ClearContent();
response.Write(String.Format(
      "<!doctype html>"+CRLF+
      "<html>" + CRLF +
      "<head><title>{0}</title></head>" + CRLF +
      "<body><h1>{0}</h1>"+CRLF+
      "{1}"+CRLF+
      "</body>" + CRLF +
      "</html>", 
      response.Status, "The grob must be in the frobber."));
response.Flush();
response.End();

The code works fine when running on the localhost (Visual Studio (2010 (Windows 7 (Professional (64-bit))))) development Cassini web-server:

HTTP/1.1 400 Bad Request
Server: ASP.NET Development Server/10.0.0.0
Date: Tue, 17 Jul 2012 15:56:42 GMT
X-AspNet-Version: 4.0.30319
Cache-Control: private
Content-Type: text/html
Connection: Close

<!doctype html>
<html>
<head><title>400 Bad Request</title></head>
<body><h1>400 Bad Request</h1>
The grob must be in the frobber.
</body>
</html>

But when i deploy the web-site to Windows Server 2008 R2 running IIS7.5, the same code doesn’t work:

HTTP/1.1 400 Bad Request
Cache-Control: private
Content-Type: text/html
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Tue, 17 Jul 2012 15:57:44 GMT
Content-Length: 11

Bad Request

How do i perform Response.Write from IIS?

  • 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-08T02:00:54+00:00Added an answer on June 8, 2026 at 2:00 am

    By default, IIS 7 will change the response if the code is >= 400
    http://msdn.microsoft.com/en-us/library/ms690497(v=vs.90).aspx

    But you can change this in the httpErrors element of system.webServer.

    <httpErrors existingResponse="PassThrough" />
    

    EDIT: this will break CustomErrors, if you are using that. You might be better off returning a 400 without a response, then setting up web.config to redirect to a custom page for 400 errors.

    <customErrors mode="On">
        <error statusCode="400" redirect="Frobber.htm" />
    </customErrors>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was trying to write out some of the implementations of the string functions
I am trying to write out custom HTML in an SSRS report. If I
Trying to write out syslog entries containing strings but they don't register. // person.name
Ultimately I'm trying to write out a range into a text file. When I
I am trying to write out a regex to get each insert line from
I'm trying to write Unicode characters (♠) using System.out , and a question mark
I'm trying to write an import function for getting data out of an excel
I'm am trying to write vba code to fill out web-forms and click buttons
I'm trying to write a jQuery function to change out href of a link,
I'm trying to write a library to separate all the disk activity out into

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.