我正在尝试写出对客户的回复:
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();
该代码在 localhost (Visual Studio (2010 (Windows 7 (Professional (64-bit)))) 开发 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>
但是当我将网站部署到运行 IIS7.5 的 Windows Server 2008 R2 时,相同的代码不起作用:
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
我如何Response.Write
从 IIS 执行?