Microsoft KB Archive/812318

= FIX: The HttpWebRequest class and the WebRequest class do not include the port number in the Request Host header when a nonstandard port is used =

Article ID: 812318

Article Last Modified on 10/21/2005

-

APPLIES TO


 * Microsoft Visual Studio .NET 2002 Professional Edition
 * Microsoft Visual Studio .NET 2002 Enterprise Architect
 * Microsoft Visual Studio .NET 2002 Enterprise Developer
 * Microsoft Visual Studio .NET 2002 Academic Edition

-





SYMPTOMS
In Microsoft Visual Studio .NET, the HttpWebRequest class and the WebRequest class do not include the port number in the Request Host header when a nonstandard port is used.

If an application uses the HttpWebRequest class or the WebRequest class when it sends a request to the server, the information set may not be sufficient to route the request to the correct port. When this behavior occurs, the server cannot return information to the application and the application fails.



Service pack information
To resolve this problem, obtain the latest service pack for the Microsoft .NET Framework 1.0. For more information, click the following article number to view the article in the Microsoft Knowledge Base:

318836 How to obtain the latest .NET Framework service pack

Hotfix information
A supported hotfix is now available from Microsoft, but it is only intended to correct the problem that this article describes. Apply it only to systems that are experiencing this specific problem.

Note You must have a Visual Studio license agreement to obtain this hotfix.

To resolve this problem, contact Microsoft Product Support Services to obtain the hotfix. For a complete list of Microsoft Product Support Services telephone numbers and information about support costs, visit the following Microsoft Web site:

http://support.microsoft.com/contactus/?ws=support

Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section. This problem was first corrected in the Microsoft .NET Framework 1.0 Service Pack 2.



MORE INFORMATION
The IsRestricted method returns a value of true to indicate that a header is restricted. You must set a restricted header by using properties instead of by setting the header directly. The restricted headers are Accept, Connection, Date, Expect, Host, Range, and Referer.

Request for Comments (RFC) 2616 states the following:

14.23 Host The Host request-header field specifies the Internet host and port number of the resource being requested, as obtained from the original URI given by the user or referring resource (generally an HTTP URL, as described in section 3.2.2). The Host field value MUST represent the naming authority of the origin server or gateway given by the original URL. This allows the origin server or gateway to differentiate between internally-ambiguous URLs, such as the root &quot;/&quot; URL of a server for multiple host names on a single IP address. Host = &quot;Host&quot; &quot;:&quot; host [ &quot;:&quot; port ]

Section 3.2.2 A &quot;host&quot; without any trailing port information implies the default port for the service requested (e.g., &quot;80&quot; for an HTTP URL). For example, a request on the origin server for  would properly include: GET /pub/WWW/ HTTP/1.1 Host: www.w3.org A client MUST include a Host header field in all HTTP/1.1 request messages. If the requested URI does not include an Internet host name for the service being requested, then the Host header field MUST be given with an empty value. An HTTP/1.1 proxy MUST ensure that any request message it forwards does contain an appropriate Host header field that identifies the service being requested by the proxy. All Internet-based HTTP/1.1 servers MUST respond with a 400 (Bad Request) status code to any HTTP/1.1 request message which lacks a Host header field.

To view RFC 2616, visit the following Internet Engineering Task Force Web site:

http://www.ietf.org/rfc/rfc2616.txt

For more information about the terminology that is used to describe Microsoft product updates, click the following article number to view the article in the Microsoft Knowledge Base:

824684 Description of the standard terminology that is used to describe Microsoft software updates

Keywords: kbbug kbfix kbqfe kbnetframe100sp2fix kbvs2002sp1sweep kbhotfixserver KB812318

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.