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方法读取 ...
随机推荐
- Ionic2使用百度地图API(JS)出现白屏解决方案
最近自学ionic2,写了一个内嵌百度地图JS的demo,实际跑起来之后出现了大家常见的白屏问题.. 最初的实现是这样的: 首先主页内嵌了一个百度地图插件 <div id="Bmap& ...
- iOS 循环轮播框架思路
使用3个imageview实现无线轮播的大致原理 将3个imageview添加到scrollview上面,scrollview的contensize是3个imageview的宽度,设置scrollvi ...
- 使用Avd 调试慢的解决方案
AVD 太慢了,不仅启动,而且运行慢.以致于要用手机去调.你觉得这样方便吗? 如果没有一个简单快速的开发调试环境,把时间都浪费在启动,调试及等待上,那是对生命的浪费. 必要条件: ...
- 转一个财务方面常用到的数字金额转成汉字大写金额 php类
系统里有牵扯到财务.合同等方面的处理时,常常需要把数字金额转成汉字大写金额(貌似这样正规),转一个转换的php class吧!<?php// 诸海加(ALPHA .z)// 2000-7-19 ...
- [原创]SpringBoot上传图片踩的坑
最近项目里面有个需求,要上传图片到阿里云的OSS服务.所以需要写个上传图片的接口给前端. 这个简单的接口本来就给分配了1个工时,感觉也蛮简单的.但编码过程中遇到了好几个问题,现在一一记录下来,避免再次 ...
- &与&& ,|与||的区别
&&和||是短路运算符,&和|是非短路运算符 &&与& 区别:两者都表示“与”运算,但是&&运算符第一个表达式不成立的话,后面的表达式不 ...
- spring切面拦截实现
1.建立业务类(英雄战斗实现类) package com.g2.api; public interface Weapon { int attack(); String getName(); } pac ...
- Servlet验证
一.servlet代码 二.验证 三.总结 在这个servlet验证过程当中,主要是解码方式的运用,特别是输入中文时容易出现乱码.在表单的action中需要输入路径. 四.网盘 链接:https:// ...
- springboot 接口返回数据时 net.sf.json.JSONNull["empty"]) 异常
@ResetController返回数据时出现异常 Could not write JSON: Object is null; nested exception is com.fasterxml.ja ...
- golang mcall
// func mcall(fn func(*g)) // Switch to m->g0's stack, call fn(g). // Fn must never return. It sh ...