码迷,mamicode.com
首页 > Web开发 > 详细

ASP.NET页面请求相关常用

时间:2014-05-07 10:21:40      阅读:335      评论:0      收藏:0      [点我收藏+]

标签:blog   tar   ext   get   strong   http   

Request下获取Url所有相关属性

测试的url地址是http://www.cnblogs.com/dachie/default.aspx?id=1

Request.Url.ToString():http://www.cnblogs.com/dachie/default.aspx?id=1

Request.ApplicationPath: /dachie

Request.CurrentExecutionFilePath: /dachie/default.aspx

Request.FilePath: /dachie/default.aspx

Request.Path: /dachie/default.aspx

Request.PathInfo:

Request.PhysicalApplicationPath: E:\WWW\testweb\

Request.PhysicalPath: E:\WWW\dachie\default.aspx

Request.RawUrl: /dachie/default.aspx?id=1

Request.Url.AbsolutePath: /dachie/default.aspx

Request.Url.AbsoluteUri: http://www.cnblogs.com/dachie/default.aspx?id=1

Request.Url.Host: www.cnblogs.com

Request.Url.LocalPath: /dachie/default.aspx

 

获取请求的IP地址

public static string GetRequestIP()

{

            string result = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

            if (string.IsNullOrEmpty(result))

            {

                result = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];

            }

            if (string.IsNullOrEmpty(result))

            {

                result = HttpContext.Current.Request.UserHostAddress;

            }

            return result;

}

 

页面后台向前台输出脚本

if (!Page.ClientScript.IsStartupScriptRegistered("preview"))

{

    Page.ClientScript.RegisterStartupScript(GetType(), "preview", "window.open(‘" + BOManager.CMSTempletBO.CreateContent(CMSTempletBO.PageType.Preview, entity) + "‘);", true);

}

ASP.NET页面请求相关常用,布布扣,bubuko.com

ASP.NET页面请求相关常用

标签:blog   tar   ext   get   strong   http   

原文地址:http://www.cnblogs.com/BruceGoGo/p/3710280.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!