Request.QueryString[""] 与 Request[""] 、 Request.QueryString[""].Tostring()
2016-01-19 16:18
211 查看
ASP.net程序是服务器控制的,你打开的网页只是服务器线程池中一个线程的运行结果,所以你即使关闭了网页,应用程序也不会关闭的
1.Request.QueryString["id"] 只能读取通过地址栏参数传递过来的名为id的参数
2.Request["id"]是一个复合功能读取函数。
3.它的优先级顺序为
QueryString > Form > Cookies > ServerVariables(服务器环境变量)
4.Request["id"]会自动按优先级搜索。
5.Request.QueryString["id"](找不到值返回null) Request.QueryString["id"].ToString()(找不到值返回null,null.ToString()会报错)
以下是Request[ "id" ]的内部实现代码:
public string this[string key]
{
get
{
string str = this.QueryString[key];
if (str != null)
{
return str;
}
str = this.Form[key];
if (str != null)
{
return str;
}
HttpCookie cookie = this.Cookies[key];
if (cookie != null)
{
return cookie.Value;
}
str = this.ServerVariables[key];
if (str != null)
{
return str;
}
return null;
}
}
<%
foreach (string x in Request.ServerVariables )
{
Response.Write(x + "<br />**" + Request.ServerVariables[x] + "<br/>!!!!");
}
%>
可以遍历所有的服务器环境变量的值。
1.Request.QueryString["id"] 只能读取通过地址栏参数传递过来的名为id的参数
2.Request["id"]是一个复合功能读取函数。
3.它的优先级顺序为
QueryString > Form > Cookies > ServerVariables(服务器环境变量)
4.Request["id"]会自动按优先级搜索。
5.Request.QueryString["id"](找不到值返回null) Request.QueryString["id"].ToString()(找不到值返回null,null.ToString()会报错)
以下是Request[ "id" ]的内部实现代码:
public string this[string key]
{
get
{
string str = this.QueryString[key];
if (str != null)
{
return str;
}
str = this.Form[key];
if (str != null)
{
return str;
}
HttpCookie cookie = this.Cookies[key];
if (cookie != null)
{
return cookie.Value;
}
str = this.ServerVariables[key];
if (str != null)
{
return str;
}
return null;
}
}
<%
foreach (string x in Request.ServerVariables )
{
Response.Write(x + "<br />**" + Request.ServerVariables[x] + "<br/>!!!!");
}
%>
可以遍历所有的服务器环境变量的值。
相关文章推荐
- iOS小技巧–用runtime 解决UIButton 重复点击问题
- UITextField
- *** does not contain bitcode. You must rebuild it with bitcode enabled
- UIPageControll - 图片格式
- 结束while(cin >> value)
- 酷炫的android开源UI
- 9.Which statement is true regarding the INTERSECT operator?
- AlertDialog.Builder用法
- Django用户认证系统 authentication system----登陆访问限制@login_required
- UIView的setNeedsLayout, layoutIfNeeded 和 layoutSubviews 方法之间的关系解释
- iOS UI界面之间传值方式的整理总结(2)单例方法
- ios UI控件关联
- <iOS Human Interface Guidelines>(iOS人机交互手册)读书笔记
- UEdit初始化加载内容偶尔失败,解决
- 解决Incorrect integer value: '' for column 'id' at row 1的方法
- Maven使用yuicompressor-maven-plugin打包压缩css、js文件
- iOS 平台UI设计小结
- UIImagePickerController显示中文界面
- UIImagePickerController显示中文界面
- 解决UITableView数据没有充满屏幕时,显示多余的空白cell的问题