我的会话值冲突的猜测 [英] Guesses of my session value conflicts

查看:59
本文介绍了我的会话值冲突的猜测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 asp.net 网络表单,它将以电子邮件的形式提交信息.每当用户填写表单并点击提交按钮时,用户输入的信息将作为电子邮件发送.

I have a asp.net web form which will submit information to come as emails. Whenever user fill the form and click on submit button,the information user entered will be sent as email.

此网络表单有 4 页.但网络表单不会在所有请求中使用所有 4 个页面.

This web form has 4 page. but the web form will not use all 4 page on all requests.

如果用户在第一页选择一个特定的值,表单将绕过第三页并进入最后的第四页(如...page1,2,4).如果它是在第一页中选择的任何其他值.表单将导航为 page1,2,3,4.

if the user select a particular value in first page, the form will bypass the 3rd page and go the last 4th page(like...page1,2,4). IF it is any other values selected in the first page. form will navigate as page1,2,3,4.

所以现在我的问题是当多个用户访问同一个网站时,第一页的值从不同的用户那里得到组合,表单会出现异常.有时会绕过有时不会绕过页面3

So now my problem is when multiple users access the same website, the value in the first page get combines from different users and the form will act abnormally.Sometime it will bypass sometimes it will not bypass the page3

下面是变量声明:

Public strRoleType As String = String.Empty
Protected Shared isAreaSelected As Integer = 0
Protected Shared isStoreSelected As Integer = 0
Protected Shared isHeadOfficeSelected As Integer = 0
Protected Shared isRegionSelected As Integer = 0

我猜问题在于 strRoleType 变量是否从不同用户获取值.

I guess the problem is with strRoleType variable whether it is getting values from different users.

有没有解决办法?

 Public Property storeSelected()
        Get
            Dim returnValue As Integer
            returnValue = Session("isStoreSelected")
            Return returnValue
        End Get
        Set(ByVal value)
            Dim outputValue As Integer = value
            Session("isStoreSelected") = outputValue
        End Set
    End Property





 Dim currentView As Int16
            currentView = mvRequestorForm.ActiveViewIndex
            If currentView = 3 And isStoreSelected = 1 Then
                mvRequestorForm.ActiveViewIndex = (currentView - 2)

            Else
                mvRequestorForm.ActiveViewIndex = (currentView - 1)
            End If

推荐答案

问题是您的变量被声明为 Shared,这意味着它们在用户之间共享.您将需要以每个用户会话获取其自己的一组值的方式存储这些值(例如在 Session 变量中).

The problem is that your variables are declared as Shared which means that they are, well, shared between the users. You will need to store these values in a way that each user session gets its own set of value (such as in a Session variable or so).

更新
当您在会话状态中存储值时,您在决定是否显示视图时读取共享变量:

If currentView = 3 And isStoreSelected = 1 Then

您还需要从会话状态中读取此内容:

You need to read this from session state as well:

If currentView = 3 And Session("isStoreSelected") = 1 Then

对Session状态值的访问最好封装在一些方法或属性中.

The access to the Session state value should preferably be encapsulated in some method or property.

这篇关于我的会话值冲突的猜测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆