asp.net中有关URL的信息

来源:网络 责任编辑:栏目编辑 发表时间:2013-07-01 18:19 点击:

【说明】如果你已经熟悉了,请不必往下看,如果你还不熟悉,请做下参考,因为经常在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

    相关新闻>>

      发表评论
      请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
      用户名: 验证码:点击我更换图片
      最新评论 更多>>

      推荐热点

      • 浅析.NET下XML数据访问新机制
      • asp.net 面试+笔试题目第1/2页
      • C# 邮件地址是否合法的验证
      • C#高级编程:数据库连接[1]
      • asp.net 设置GridView的选中行的实现代码
      • 经典C++程序1
      • IIS 自动回收导致后台定时器失效的问题解决
      • ASP.NET&#160;GridView列表代码示例
      • 微软ASP.NET站点部署指南(3):使用Web.Config文件的Transforma
      网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
      Copyright © 2008-2015 计算机技术学习交流网. 版权所有

      豫ICP备11007008号-1