ASP.NET学习日记

        初学.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的文章

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值