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方法读取 ...
随机推荐
- windows下安装ubuntu15.04
本文主要介绍windows下安装ubuntu15.04,对与其他的版本也是适用的.现在要讲的是一种最简单ubuntu的安装方式. 1软件下载 1.磁盘分区工具DiskGenius 2.启动项修改工具E ...
- stl容器学习——queue,stack,list与string
目录 头文件 string 目录部分 1.string的定义及初始化 ① 用一个字符串给另一个字符串赋值 ②用字符串常量对字符串进行赋值 ③ 用n个相同的字符对字符串赋值 2.string的运算符及比 ...
- 移动端尺寸新写法-rem
rem这是个低调的css单位,近一两年开始崭露头角,有许多同学对rem的评价不一,有的在尝试使用,有的在使用过程中遇到坑就弃用了.但是我对rem综合评价是用来做web app它绝对是最合适的人选之一. ...
- c++ 用 0x3f3f3f3f 设定最大int值的优点
在许多算法中都要用到一个常量来表示最大值,例如:寻找一个最小数,就要先设定一个值a,如果比a小,a就等于这个数:再如,最短路径中基本的松弛操作: 0 在c++中可以用memset() 来初始化数组成最 ...
- 1095. Maximum Swap —— Weekly Challenge
题目限定输入是[0, 10^8],因而不用考虑负数或者越界情况,算是减小了难度. public class Solution { /** * @param num: a non-negative in ...
- MonoGame2D - MonoGame的2D威力加强版
简介MonoGame2D 是一款基于MonoGame的扩展工具包,对MonoGame的2D开发方面进行了扩展,主要增加了精灵,字体,地图,组件,GUI等游戏开发中的一些基本元素,以更方便快捷地进行2D ...
- window.onresize事件在vue项目中的应用
//vue页面<template> <div id='echart'> 报表 </div> </template> <script> exp ...
- Python RawSocket Syn
#!/bin/env python # -*- coding: UTF-8 -*- # 必须以root权限运行 import socket import sys import time import ...
- Robot Framework_Ride(Settings)
Settings 不管是测试套件还是测试用例都会有一个“Settings>>”的按钮,因为它默认是被折叠起来的,所以,一般不太容易发现它,更不知道点击它之后是可以展开的 1.测试用例的 S ...
- IE的haslayout的触发
原文连接:http://www.cnblogs.com/yunxuange/archive/2012/09/19/2693886.html layout是Windows上的IE浏览器产生许多bug的根 ...