locked
Update Panel shows data from multiple users RRS feed

  • Question

  • User463812309 posted

    Hello,

    I have a web app with multiple pages relating to performing Exchange tasks for non exchange administrators.

    One of these pages will allow a user to view / add / remove permissions from a mailbox.

    It works fine, but the viewing takes around 40 seconds because of all the calls to exchange cmdlets.

    So, I thought I'd add an Update Panel and provide progress on each step. 

    That works great if only one user uses the page at a time, but if multiple people run it, the data is either combined for both or one person gets the other's data.

    This is my update panel:

     <asp:UpdatePanel ID="pnlResults" runat="server" UpdateMode="Conditional" Visible="false" ChildrenAsTriggers="false">
                <ContentTemplate>
                    <asp:Label ID="lblResults" runat="server" Height="150px"></asp:Label>
                    <br />
                    <asp:TextBox ID="txtProgress" runat="server" Visible="false" TextMode="MultiLine" BorderStyle="None" Width="95%" Style="overflow: hidden;" AutoPostBack="false"></asp:TextBox>
                    <br />
                    <br />
                    <asp:Table ID="thePermissionTable" runat="server" AutoPostBack="true" BorderStyle="None"></asp:Table>
                    <br />
                    <asp:Button ID="btnRemoveAccess" runat="server" Visible="false" Text="!Remove Access!"></asp:Button>
                    <br />
                    <asp:Button ID="btnBack" Text="Return" runat="server" OnClick="BtnBack_Click" Visible="true" AutoPostBack="true"></asp:Button>
                    <asp:TextBox ID="txtPermissionToRevoke" runat="server" Width="0px" Height="0px" BorderStyle="None"></asp:TextBox>
                    <asp:TextBox ID="txtSendOnBehalf" runat="server" Width="0px" Height="0px" BorderStyle="None"></asp:TextBox>
                    <asp:TextBox ID="txtSendOnBehalfToRevoke" runat="server" Width="0px" Height="0px" BorderStyle="None"></asp:TextBox>
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
                </Triggers>
            </asp:UpdatePanel>

    This is timer1_tick:

    protected void Timer1_Tick(object sender, EventArgs e)
        {
            if (inProcess)
            {
                txtProgress.Rows = content.Split('\r').Length + 1;
                txtProgress.Text = content;
            }
            if (processComplete && content.Substring(content.Length - processCompleteMsg.Length) == processCompleteMsg) //has final message been set?
            {
                inProcess = false;
                btnNext.Visible = false;
                btnBack.Visible = true;
                txtProgress.Text = content;
                if (tableDone)
                {
                    if (rdoAction.SelectedValue.ToString().ToLower() == "remove-access")
                    {
                        pnlButtons.Visible = true;
                        btnRemoveAccess.Visible = true;
                    }
                    thePermissionTable.Visible = true;
                }
                Timer1.Enabled = false;
            }
            else
            {
                if (displayTable)
                    CreateTable();
                if (rdoAction.SelectedValue.ToString().ToLower() == "remove-access")
                {
                    pnlButtons.Visible = true;
                    btnRemoveAccess.Visible = true;
                }
            }
        }

    I start the process with my button click in RaisePostBackEvent like so:
                       switch (action)
                        {
                            case "display-access":
                                Timer1.Enabled = true;
                                inProcess = true;
                                pnlButtons.Visible = false;
                                Thread workerThread = new Thread(new ThreadStart(() =>
                                {
                                    FnGetCurrentAccess();
                                }));
                                workerThread.Start();
                                break;
    }

    FnGetCurrentAccess() does almost all of the exchange cmdlets by calling my commonfunctions class, and adds to the content which is a private static string.

    I have no idea how to make this work, so I appreciate any ideas.

    Karl

    Wednesday, March 31, 2021 10:23 PM

All replies

  • User-939850651 posted

    Hi Karl Mitschke,

    Based on the information you provided, I am still confused about the problem. Because it contains a lot of unknown controls or variables (such as button RaisePostBackEvent , rdoAction), I am not sure of their specific role in the execution process, so I'm afraid I can't determine your current problem. 

    If possible, could you describe your problem more clearly? And sample code that can reproduce the problem?

    Best regards,

    Xudong Peng

    Thursday, April 1, 2021 4:28 AM
  • User409696431 posted

    "FnGetCurrentAccess() does almost all of the exchange cmdlets by calling my commonfunctions class, and adds to the content which is a private static string."

    Static strings retain their values across user sessions.  All users will see the same value in that string, and all users will be adding data to the same string.

    Don't use a static string.  Use storage specific to the user.   I don't know how your code works, but typically it would be session or just a string, not a static string.  If you use a string, you'll need to pass it to your functions.

    Friday, April 2, 2021 11:00 PM