평가 및 의견을 보내려면 클릭하십시오.
MSDN
MSDN Library
.NET 개발
이전 버전
.NET Framework SDK 2.0
Class Library Reference
System.Net
HttpListenerRequest 클래스

  저대역폭 보기 설정
이 페이지에서 다루는 특정 제품:.
Microsoft Visual Studio 2005/.NET Framework 2.0

다음 제품들은 다른 버전에서 다루어 집니다.
.NET Framework 클래스 라이브러리
HttpListenerRequest 클래스

참고: 이 클래스는 .NET Framework 버전 2.0에서 새로 추가되었습니다.

HttpListener 개체에 대한 들어오는 HTTP 요청을 설명합니다. 이 클래스는 상속될 수 없습니다.

네임스페이스: System.Net
어셈블리: System(system.dll)

Visual Basic(선언)
Public NotInheritable Class HttpListenerRequest
Visual Basic(사용법)
Dim instance As HttpListenerRequest
C#
public sealed class HttpListenerRequest
C++
public ref class HttpListenerRequest sealed
J#
public final class HttpListenerRequest
JScript
public final class HttpListenerRequest

클라이언트가 HttpListener 개체에서 처리되는 URI(Uniform Resource Identifier)에 요청을 하면 HttpListener에서는 송신자, 요청 및 클라이언트에 보내는 응답에 대한 정보가 들어 있는 HttpListenerContext 개체를 제공합니다. HttpListenerContext.Request 속성은 요청을 설명하는 HttpListenerRequest 개체를 반환합니다.

HttpListenerRequest 개체에는 요청의 HttpMethod 문자열, UserAgent 문자열 및 요청 본문 데이터(InputStream 속성 참조)와 같은 요청 관련 정보가 들어 있습니다.

요청에 회신하려면 Response 속성을 사용하여 관련 응답을 가져와야 합니다.

다음 코드 예제에서는 HttpListenerRequest를 받고 이에 응답하는 방법을 보여 줍니다.

C#
// This example requires the System and System.Net namespaces.
public static void SimpleListenerExample(string[] prefixes)
{
    if (!HttpListener.IsSupported)
    {
        Console.WriteLine ("Windows XP SP2 or Server 2003 is required to use the HttpListener class.");
        return;
    }
    // URI prefixes are required,
    // for example "http://contoso.com:8080/index/".
    if (prefixes == null || prefixes.Length == 0)
      throw new ArgumentException("prefixes");
    
    // Create a listener.
    HttpListener listener = new HttpListener();
    // Add the prefixes.
    foreach (string s in prefixes)
    {
        listener.Prefixes.Add(s);
    }
    listener.Start();
    Console.WriteLine("Listening...");
    // Note: The GetContext method blocks while waiting for a request. 
    HttpListenerContext context = listener.GetContext();
    HttpListenerRequest request = context.Request;
    // Obtain a response object.
    HttpListenerResponse response = context.Response;
    // Construct a response.
    string responseString = "<HTML><BODY> Hello world!</BODY></HTML>";
    byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString);
    // Get a response stream and write the response to it.
    response.ContentLength64 = buffer.Length;
    System.IO.Stream output = response.OutputStream;
    output.Write(buffer,0,buffer.Length);
    // You must close the output stream.
    output.Close();
    listener.Stop();
}
System.Object
  System.Net.HttpListenerRequest
이 형식의 모든 public static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

Windows 98, Windows Server 2003, Windows XP Media Center Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

.NET Framework

2.0에서 지원
커뮤니티 콘텐츠   커뮤니티 콘텐츠란?
새 콘텐츠 추가 RSS  주석
Processing
© 2009 Microsoft Corporation. All rights reserved. 사용약관  |  상표  |  개인정보보호
Page view tracker