初学.NET时记录了很多学习日记,现在看看还是比较有用的,于是想把它们更新的网络上来,与大家一起分享。
1、Response.Cache.Setcacheability(System.Web.HttpCacheability.Nocatch)
使页面缓存失效,每次都要重新获取新页面,因此可以屏蔽掉后退时间
此外,由于Session并不稳定,在很多机器上都不能够正常度过它的生存周期就消失掉了。(原因我也只是猜测,等有确定答案后会发出来)
2、获取所有的URL或Form参数
注:request.querystring或者request.form取出来的信息有自己的特定规则;
偶的代码:
'获取所有querystring参数信息
ParamAllNameList = Request.QueryString
If ParamAllNameList.Count > 0 Then
Dim i As Integer
For i = 0 To ParamAllNameList.count - 1
ParamAllValue = ParamAllValue + ParamAllNameList.getvalues(ParamAllNameList.keys(i))(0).tostring + "@"
ParamAllName = ParamAllName + ParamAllNameList.keys(i) + "@"
Next
End If
'获取所有form参数信息
ParamAllNameList = Request.Form
If ParamAllNameList.Count > 0 Then
Dim i As Integer
For i = 0 To ParamAllNameList.count - 1
ParamAllValue = ParamAllValue + ParamAllNameList.getvalues(ParamAllNameList.keys(i))(0).tostring + "@"
ParamAllName = ParamAllName + ParamAllNameList.keys(i) + "@"
Next
If ParamAllValue <> "" Then ParamAllValue.Substring(1, ParamAllValue.Length - 1)
If ParamAllName <> "" Then ParamAllName.Substring(1, ParamAllName.Length - 1)
End If
3、偶在解决Response.redirect问题的代码
首先偶响应了一下微软的号召重载了Reponse.redirect函数具体代码如下
Public Shared Sub Redirect(ByVal response As System.Web.HttpResponse, ByVal path As String, Optional ByVal endResponse As Boolean = False)
response.ClearContent()
response.AppendHeader("Location", path)
response.StatusCode = 302'向Http发送302状态,转到客户端重定向
If endResponse Then
'response.End()以前偶用response.end总是报错,一般情况它不会中止掉程序,可以Catch住,但真正应用的时候可能会造成请求超时
HttpContext.Current.ApplicationInstance.CompleteRequest()'与response.end作用类似
End If
End Sub
具体解决思路,请参考本人首页上关于response.redirect和response.end的文章