新闻动态
新闻动态
- 没有数据分析何谈SEO?
- innerhtml 用法
- 提升用户体验度要注意的几点
- C#中类的方法(构造方法)
- .net中除了增删改查之外的一些方法
- Document write()、writeln()方法
- 讲述网络营销的五个标准
- 学前SEO应做哪些准备
- dtcms系统架构
- document对象详解
联系我们
邮箱:
手机:15383239821
asp.net
c#中错误提示:当前上下文中不存在名称“Request”
作者:
发布时间:2020-08-21
点击:
想获取客户端ip地址,使用了下面语句
string _ip = request.ServerVariables.Get("Remote_Addr").ToString().Trim();
但是会提示错误:当前上下文中不存在名称“Request”
其实只需要前面加上 HttpContext.Current. 就可以了,改为
string _ip =HttpContext.Current.Request.ServerVariables.Get("Remote_Addr").ToString().Trim();
或者加上 System.Web.HttpContext.Current
其它:当前上下文中不存在名称"Server"也是同样的道理
HttpFileCollection files = System.Web.HttpContext.Current.Request.Files;
string url = System.Web.HttpContext.Current.Server.MapPath("/File/" + gfilename + filenameext);
新闻资讯
-
2010-12-09什么是软文,软文该怎么写?
-
2010-10-23常用的存储过程
-
2023-03-23apache的.htaccess规则
-
2012-10-09怎么看关键词优化得好不好?
-
2019-11-21C#中类的实例化
-
2023-09-21php入口文件定义 IN_IA 常量
相关案例
