HttpWebResponse.ContentEncoding-Eigenschaft
Ruft die Methode ab, die zum Codieren des Textkörpers der Antwort verwendet wird.
Namespace: System.Net
Assembly: System (in system.dll)
Syntax
'Declaration
Public ReadOnly Property ContentEncoding As String
'Usage
Dim instance As HttpWebResponse
Dim value As String
value = instance.ContentEncoding
public string ContentEncoding { get; }
public:
property String^ ContentEncoding {
String^ get ();
}
/** @property */
public String get_ContentEncoding ()
public function get ContentEncoding () : String
Eigenschaftenwert
Eine Zeichenfolge, die die Methode beschreibt, die zum Codieren des Textkörpers der Antwort verwendet wird.
Ausnahmen
Ausnahmetyp | Bedingung |
---|---|
Die aktuelle Instanz wurde bereits verworfen. |
Hinweise
Die ContentEncoding-Eigenschaft enthält den Wert des mit der Antwort zurückgegebenen Content-Encoding-Headers.
Beispiel
Im folgenden Beispiel wird die ContentEncoding-Eigenschaft verwendet, um den Wert des in der Antwort zurückgegebenen Content-Encoding-Headers abzurufen.
Try
Dim myHttpWebRequest As HttpWebRequest = CType(WebRequest.Create(url), HttpWebRequest)
Dim myHttpWebResponse As HttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
Console.WriteLine(("The encoding method used is: " + myHttpWebResponse.ContentEncoding))
Console.WriteLine(("The character set used is :" + myHttpWebResponse.CharacterSet))
Dim seperator As Char = "/"c
Dim contenttype As [String] = myHttpWebResponse.ContentType
' Retrieve 'text' if the content type is of 'text/html.
Dim maintype As [String] = contenttype.Substring(0, contenttype.IndexOf(seperator))
' Display only 'text' type.
If [String].Compare(maintype, "text") = 0 Then
Console.WriteLine(ControlChars.NewLine + " Content type is 'text'.")
try
{
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
Console.WriteLine("The encoding method used is: " + myHttpWebResponse.ContentEncoding);
Console.WriteLine("The character set used is :" + myHttpWebResponse.CharacterSet);
char seperator = '/';
String contenttype = myHttpWebResponse.ContentType;
// Retrieve 'text' if the content type is of 'text/html.
String maintype = contenttype.Substring(0,contenttype.IndexOf(seperator));
// Display only 'text' type.
if (String.Compare(maintype,"text") == 0)
{
Console.WriteLine("\n Content type is 'text'.");
try
{
HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( url ) );
HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() );
Console::WriteLine( "The encoding method used is: {0}", myHttpWebResponse->ContentEncoding );
Console::WriteLine( "The character set used is : {0}", myHttpWebResponse->CharacterSet );
char separator = '/';
String^ contenttype = myHttpWebResponse->ContentType;
// Retrieve 'text' if the content type is of 'text/html.
String^ maintype = contenttype->Substring( 0, contenttype->IndexOf( separator ) );
// Display only 'text' type.
if ( String::Compare( maintype, "text" ) == 0 )
{
Console::WriteLine( "\n Content type is 'text'." );
try {
HttpWebRequest myHttpWebRequest = (HttpWebRequest)
WebRequest.Create(url);
HttpWebResponse myHttpWebResponse = (HttpWebResponse)
myHttpWebRequest.GetResponse();
Console.WriteLine("The encoding method used is: "
+ myHttpWebResponse.get_ContentEncoding());
Console.WriteLine("The character set used is :"
+ myHttpWebResponse.get_CharacterSet());
char seperator = '/';
String contentType = myHttpWebResponse.get_ContentType();
// Retrieve 'text' if the content type is of 'text/html.
String mainType = contentType.Substring(0,
contentType.IndexOf(seperator));
// Display only 'text' type.
if (String.Compare(mainType,"text") == 0) {
Console.WriteLine("\n Content type is 'text'.");
Plattformen
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
.NET Compact Framework
Unterstützt in: 2.0, 1.0
Siehe auch
Referenz
HttpWebResponse-Klasse
HttpWebResponse-Member
System.Net-Namespace