HtmlTextWriter.WriteEncodedUrl(String) 方法

定义

对指定的 URL 进行编码,然后将它写入到输出流。Encodes the specified URL, and then writes it to the output stream. URL 可以包括参数。The URL might include parameters.

public:
 virtual void WriteEncodedUrl(System::String ^ url);
public virtual void WriteEncodedUrl (string url);
abstract member WriteEncodedUrl : string -> unit
override this.WriteEncodedUrl : string -> unit
Public Overridable Sub WriteEncodedUrl (url As String)

参数

url
String

要进行编码并写入到输出流的 URL 字符串。The URL string to encode and write to the output stream.

示例

下面的代码示例演示如何使用WriteEncodedUrl方法,该方法生成以下输出:The following code example shows how to use the WriteEncodedUrl method, which generates the following output:

http://localhost/Sample%20Folder/Sample%20%2b%20File.txt

// Assign a value to a string variable
// and URL-encode it to a page.
url = "http://localhost/SampleFolder/Sample + File.txt"; 
writer.WriteBreak();
writer.WriteEncodedUrl(url);
writer.WriteBreak();
' Assign a value to a string variable
' and URL-encode it to a page.
url = "http://localhost/SampleFolder/Sample + File.txt" 
writer.WriteBreak()
writer.WriteEncodedUrl(url)
writer.WriteBreak()

注解

方法根据 URL 编码规范对url参数中的字符串进行编码。 WriteEncodedUrlThe WriteEncodedUrl method encodes the string in the url parameter in accordance with the specification for URL encoding. 问号(?)分隔符后面的参数不进行编码。The parameters that follow the question mark (?) delimiter are not encoded.

适用于

另请参阅