SendStatus() public method

public SendStatus ( int statusCode, string statusDescription ) : void
statusCode int
statusDescription string
return void
示例#1
0
        static void Redirect(XSPWorkerRequest wr, string location)
        {
            string host = wr.GetKnownRequestHeader(HttpWorkerRequest.HeaderHost);

            wr.SendStatus(301, "Moved Permanently");
            wr.SendUnknownResponseHeader("Connection", "close");
            wr.SendUnknownResponseHeader("Date", DateTime.Now.ToUniversalTime().ToString("r"));
            wr.SendUnknownResponseHeader("Location", String.Format("http://{0}{1}", host, location));
            Encoding enc = Encoding.ASCII;

            wr.SendUnknownResponseHeader("Content-Type", "text/html; charset=" + enc.WebName);
            string content = String.Format(content301, host, location);

            byte [] contentBytes = enc.GetBytes(content);
            wr.SendUnknownResponseHeader("Content-Length", contentBytes.Length.ToString());
            wr.SendResponseFromMemory(contentBytes, contentBytes.Length);
            wr.FlushResponse(true);
            wr.CloseConnection();
        }
示例#2
0
 static void Redirect(XSPWorkerRequest wr, string location)
 {
     string host = wr.GetKnownRequestHeader (HttpWorkerRequest.HeaderHost);
     wr.SendStatus (301, "Moved Permanently");
     wr.SendUnknownResponseHeader ("Connection", "close");
     wr.SendUnknownResponseHeader ("Date", DateTime.Now.ToUniversalTime ().ToString ("r"));
     wr.SendUnknownResponseHeader ("Location", String.Format ("http://{0}{1}", host, location));
     Encoding enc = Encoding.ASCII;
     wr.SendUnknownResponseHeader ("Content-Type", "text/html; charset=" + enc.WebName);
     string content = String.Format (CONTENT301, host, location);
     byte [] contentBytes = enc.GetBytes (content);
     wr.SendUnknownResponseHeader ("Content-Length", contentBytes.Length.ToString ());
     wr.SendResponseFromMemory (contentBytes, contentBytes.Length);
     wr.FlushResponse (true);
     wr.CloseConnection ();
 }