1、js判断:
function CheckUrl(){
//设置获取href属性中跟在问号后面的部分
var url=window .location .search;
if (url.length >50)
{
location.href="index.aspx";
}
}
调用:
<script >CheckUrl();</script>
2、函数判断:
public static bool checkUrlParameters(HttpRequest Request)
{
bool bOk = true;
int iLen = 0;
foreach (string sPara in Request.QueryString)
{
iLen = Request.QueryString[sPara].ToString().Length;
if (iLen > 50)
{
bOk = false;
break;//参数太长
}
}
return bOk;
}
调用:
checkUrlParameters(Request);