Đỉnh NGUYỄN

life's a journey not a destination

Cách truy xuất các phần của URL trong ASP.NET

Leave a comment


Dùng lớp URI. Và đây là ví dụ:

protected void Page_Load(object sender, EventArgs e)
{
    Uri someUri = Page.Request.Url;
    string urlstr = string.Format(
        "AbsoluteUri: {0}<br /> Scheme: {1}<br /> Host: {2}<br /> Port: {3}<br /> Query: {4} ",
        someUri.AbsoluteUri, someUri.Scheme, someUri.Host, someUri.Port, someUri.Query);
    Response.Write(urlstr);
}

Advertisements

Author: dinhnn

Senior software developer, a technical leader. You can be reached at via email to dinhnguyenngoc@gmail.com, via my blog at dinhnguyenngoc.wordpress.com, and on Twitter @dinhnguyenngoc.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s