csharp: Request.Form,Request.QueryString,Request.Params,Request.Cookies
/// <summary>
/// Request.Form,Request.QueryString,Request.Params
/// http://msdn.microsoft.com/en-us/library/system.web.httprequest.params(v=vs.110).aspx
/// Geovin Du 涂聚文
/// 2014-05-28
///Request.Form (for POST) and Request.QueryString (for GET).
///Request.Params是所有post和get传过来的值的集合,request.params其实是一个集合,它依次包括 request.QueryString、request.Form、request.cookies和request.ServerVariable。
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Button1_Click(object sender, EventArgs e)
{
GeovinduVip.Common.ProcessRequest pr = new GeovinduVip.Common.ProcessRequest(); // Create a string to contain the paramaters'
// information.
string paramInfo = ""; // Obtain a reference to the Request.Params
// collection.
NameValueCollection pColl = Request.Params; // Iterate through the collection and add
// each key to the string variable.
for (int i = 0; i <= pColl.Count - 1; i++)
{
paramInfo += "Key: " + pColl.GetKey(i) + "<br />"; // Create a string array that contains
// the values associated with each key.
string[] pValues = pColl.GetValues(i); // Iterate through the array and add
// each value to the string variable.
for (int j = 0; j <= pValues.Length - 1; j++)
{
paramInfo += "Value:" + pValues[j] + "<br /><br />";
if (!string.IsNullOrEmpty(pValues[j].ToString()))
{
if (ProcessSqlStr(pValues[j].ToString(), 1) == false) //pr.ProcessSqlStr
{
Jscript.Alert("存在非法字符!");
//Response.End();
//return;
}
} }
} // Set a Label's Text property to the values
// contained in the string variable.
//Response.Write(paramInfo); Response.Write("Request.Form.AllKeys:");
//Request.Form.AllKeys; string[] FormColl = Request.Form.AllKeys; for (int j = 0; j <= FormColl.Length - 1; j++)
{
Response.Write(FormColl[j].ToString()+"="+ Request.Form[FormColl[j]] + "<br />");
Response.Write( "<br />");
} Response.Write("Request.Form:"); foreach (string key in Request.Form.Keys)
{
Response.Write(key+"="+Request.Form[key] + "<br />");
}
Response.Write("Request.Form:End <br/>"); Response.Write("Request.QueryString:");
foreach (string key in Request.QueryString.Keys)
{
Response.Write(key+"="+Request.QueryString[key] + "<br />");
}
Response.Write("Request.QueryString:End <br/>");
Response.Write("Request.Params:");
foreach (string key in Request.Params.Keys)
{
Response.Write(String.Format("{0}: {1}<br />", key, Request.Params[key]));
}
}
if (Request.Cookies != null)
{
for (int i = 0; i < Request.Cookies.Count; i++)
{
Response.Write(Request.Cookies[Request.Cookies.Keys[i]].Value); }
}
Dictionary<string, object> dict = we.TheRest;
//Response.Write(we.TheRest["WD"].ToString());
//for (int i = 0; i < dict.Count; i++)
//{
// Response.Write(dict.Keys.ToString());
// Response.Write(dict.Values.ToString()); //}
foreach (KeyValuePair<string, object> kvp in dict)
{
//outputBlock.Text += String.Format("Key = {0}, Value = {1}", kvp.Key, kvp.Value) + "\n";
string s = string.Format("键是:{0} 值是:{1}", kvp.Key.ToString(), (!object.Equals(kvp.Value, null) ? kvp.Value.ToString(): ""));
Response.Write(s);
} //Hashtable dict = new Hashtable();
//foreach (DictionaryEntry i in dict)
//{
// string s = string.Format("键是:{0} 值是:{1}", i.Key.ToString(), i.Value.ToString());
// Response.Write(s);
//} }
csharp: Request.Form,Request.QueryString,Request.Params,Request.Cookies的更多相关文章
- Request.params,Request.form,Request.querystring区别(转)
自己总结:---大致意思是: 1.传参的方式分为:get方式传参,post方式传参,request.cookies和request.servervariables 2.这几种获取参数方式获取的都是一个 ...
- Request.Form()的使用
在CS文件中获得对应页面中的下拉框DropDownList_sitebranch值可以有以下几种方法获得: siteInfo.FZJGID = DropDownList_sitebra ...
- request.form()和request()的区别
Request.Form:获取以POST方式提交的数据(接收Form提交来的数据):Request.QueryString:获取地址栏参数(以GET方式提交的数据)Request:包含以上两种方式(优 ...
- System.Web.HttpRequestValidationException: 从客户端(name="<a href=''>我是晓菜鸟</a>")中检测到有潜在危险的 Request.Form 值
这是一个比较常见的问题了,如果Web表单中有输入类似于 Html 标签之类的文本,在通过 Request.QueryString 或者 Request.Form 传递这些值的时候,就会触发这样的异常, ...
- 转载:检测到有潜在危险的 Request.Form 值
转载:检测到有潜在危险的 Request.Form 值 金刚 ASP.NET Request.Form 这是一篇转载的文章,文章原始出处.点我 这种问题是因为你提交的Form中有HTML字符串,例如你 ...
- WebAPI.请求(Request)的参数(Parameter)里包含特殊字符(#等)的正确处理方式 从客户端xx中检测到有潜在危险的Request.Form值
事故现场 报错"从客户端 中检测到有潜在危险的Request.Form值" //后台代码 namespace Test { [RoutePrefix("TestClass ...
- C#中 Request, Request.params , Request.querystring , Request.Form 区别 与联系用法
C#中 Request, Request.params , Request.querystring , Request.Form 区别 与联系用法? Request.params , Request ...
- Request.QueryString["id"] 、Request.Params["id"] 的强大
<form> <input type="text" name="id" value="值"> </form&g ...
- request.querystring和request.form、session的区别
1. request.querystring是用来接收地址里面问号“?”后面的参数的内容, 用get方法读取的 不安全 request.form是用来接收表单递交来的数据 ,是用post方法读取 ...
随机推荐
- unity里的c#
类方法:start只进行一次,update每一帧都会进行调用 拖动脚步到对应物体就可以将其关联 定义变量与c++相似 F2修改文件名 脚本的类名要与文件名保持一致 数组的定义:1.类型[] 数组名={ ...
- 2018年1月17日总结 css3里transition 和animation 区别
transition 和animation两个CSS3属性经常被用到实际项目中,想把它整理出来. 1.先介绍transition >>>>> a. 在做项目中经常会遇见 ...
- C#找出接口的所有实现类并遍历执行这些类的公共方法
//这里找出了实现IOutputArray接口的所有类 private void FindAllClass() { var types = AppDomain.CurrentDomain.GetAss ...
- flask开发笔记
目录 虚拟环境 Debug模式 配置文件 url传入参数 url反转 重定义向 模板 创建 jinjia2语法 模板继承 flash 加载静态文件 MySQL数据库命令 配置 更新.提交.删除 模型操 ...
- 微信小程序回到顶部的两种方式
一,使用view形式的回到顶部 <image src='../../img/button-top.png' class='goTop' hidden='{{!floorstatus}}' bin ...
- 如何为 Vue 项目写单元测试
https://www.w3ctech.com/topic/2052 如何为 Vue 项目写单元测试 前端工程 明非 2017-07-18 4685 访问 1 分享 微信分享 译者:明非 链接:htt ...
- line-height详解
line-height详解 要说line-height就必须要知道这几个概念了: 顶线.中线.基线.底线. 这也就是在vertical-align中可能用到的top,middle,baseline和b ...
- 在VM虚拟机中彻底删除Linux系统
前言:很久之前安装了Linux虚拟系统,然后用户名忘记了,想着重新安装个Ubuntu系统,就想着删除以前的系统. 删除方法如下: 1.点击打开该Linux系统. 2. 点击虚拟机的左上方“虚拟机”-& ...
- datepicker97切换年月日再连续点击下拉中日期的bug出现问题
解决办法: function wdateOption(fmt){ if(fmt===undefined){fmt="yyyy-MM-dd"} return{ dateFmt:fmt ...
- Oracle 行列转换总结
行列转换包括以下六种情况:*列转行*行转列*多列转换成字符串*多行转换成字符串*字符串转换成多列*字符串转换成多行 下面分别进行举例介绍. 首先声明一点,有些例子需要如下10g及以后才有的知识:a.掌 ...