asp.net中有关URL的信息
【说明】如果你已经熟悉了,请不必往下看,如果你还不熟悉,请做下参考,因为经常在asp.net中需要获取有关URL相关方面的信息,虽然msdn上列出了各种方法,无奈方法和属性太多,没办法一一记住,就做了个例子,将与路径和文件信息相关的参数通过一个方法列出来,以备平时查阅。
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class AjaxDemo : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("Request.AppRelativeCurrentExecutionFilePath=" + Request.AppRelativeCurrentExecutionFilePath + "<br>");
Response.Write("Request.CurrentExecutionFilePath=" + Request.CurrentExecutionFilePath + "<br>");
Response.Write("Request.FilePath=" + Request.FilePath + "<br>");
Response.Write("Request.Path=" + Request.Path + "<br>");
Response.Write("Request.PathInfo=" + Request.PathInfo + "<br>");
Response.Write("Request.PhysicalApplicationPath=" + Request.PhysicalApplicationPath + "<br>");
Response.Write("Request.PhysicalPath=" + Request.PhysicalPath + "<br>");
Response.Write("Request.RawUrl=" + Request.RawUrl + "<br>");
Response.Write("Request.Url=" + Request.Url + "<br>");
Response.Write("Request.UrlReferrer=" + Request.UrlReferrer + "<br>");
Response.Write("Request.UserHostAddress=" + Request.UserHostAddress + "<br>");
Response.Write("Request.UserHostName=" + Request.UserHostName + "<br>");
Uri uri = Request.Url;
Response.Write("uri.AbsolutePath=" + uri.AbsolutePath + "<br>");
Response.Write("uri.AbsoluteUri=" + uri.AbsoluteUri + "<br>");
Response.Write("uri.Authority=" + uri.Authority + "<br>");
Response.Write("uri.Host=" + uri.Host + "<br>");
Response.Write("uri.HostNameType=" + uri.HostNameType + "<br>");
Response.Write("uri.Scheme=" + uri.Scheme + "<br>");
Response.Write("uri.LocalPath=" + uri.LocalPath + "<br>");
Response.Write("uri.OriginalString=" + uri.OriginalString + "<br>");
Response.Write("uri.PathAndQuery=" + uri.PathAndQuery + "<br>");&nbs
相关新闻>>
- 发表评论
-
- 最新评论 更多>>