Is a way to authenticate a user going from one multiview control to another?

I have a multiview control with two views.

The first view called vwPersonalData presents user's original selections.

The second view called vwPreviewData displays user's selections from vwPersonalData so user can preview data and make changes if possible.

Here is a sample:

             <asp:MultiView ID="myMultiView" ActiveViewIndex="0" runat="server">
              <asp:View ID="vwPersonalData" runat="server">
              ...
              ...
              ...
              </view>
              <asp:View ID="vwPreviewData" runat="server">
              ..
              ..
              ..
              </view>
             </MultiView>  

Open in new window


If no changes are necessary, user clicks Checkout and this takes user to a third party payment gateway.
Before a user get's to the preview page, s/he is prompted to either login or sign up and then login.

Once the user logs  in successfully, s/he is then automatically redirected to Preview page.

The issue is that once the user is redirected to the preview page, all of the user's selections are removed.

If no authentication is needed,everything works great.

I have tried adding the following code to the pageLoad event with no success.

        If Session("UserEmail") Is Nothing Then
            ' Redirect user to login before doing anything else
            Response.Redirect("~/Login.aspx?redirect=requestSummary.aspx")
        End If

Open in new window


Then I tried adding to the Next button event which is the vwPersonalData view control with hope that the user would be taken to btnSend event which is the vwPreviewData view control but again, all user's selection is wiped out.
    Protected Sub btnNext_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        If Session("UserEmail") Is Nothing Then
            ' Redirect user to login before doing anything else
            Response.Redirect("~/Login.aspx?redirect=requestSummary.aspx")
        End If
        myMultiView.ActiveViewIndex += 1
    End Sub
    Protected Sub btnSend_Click(ByVal sender As Object, ByVal e As EventArgs)
    End Sub

Open in new window


Is there a way around this?

Thanks in advance
LVL 29
sammySeltzerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CodeCruiserCommented:
Have you tried stepping through following code to see whether if condition is true or not when user first visits site?

If Session("UserEmail") Is Nothing Then
            ' Redirect user to login before doing anything else
            Response.Redirect("~/Login.aspx?redirect=requestSummary.aspx")
        End If
sammySeltzerAuthor Commented:
The IF condition works great. That's not the issue.

It is redirecting correctly. The issue is that once the user is redirected, the values that are supposed to be resident at the destination page are wiped off.

Without the IF condition, everything works great.
CodeCruiserCommented:
Are you storing control values in session and reloading? If not, when you visit another page (login) and then come back to this page then obviously it will be reinitialised.
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

sammySeltzerAuthor Commented:
Sorry for late response on this CodeCruiser.

I got tied up with another project.

Here is what I am doing so far:

User clicks on a link and the following are passed is passed to multiview vwPersonalData control:

              <asp:HyperLink ID="hdReserve" class="js_siteid"  AutoPostBack="false" runat="server" Text="Select" 
                Navigateurl='<%# String.Format("requestSummary.aspx?id={0}&groupsize={1}&facilityFees={2}&depoitAmt={3}&cancelAmt={4}&keydeptAmt={5}&extrahour={6}&facility={7}&hoursdiff={8}", CType(Container.DataItem, System.Data.DataRowView)("siteId") , ddlPartySize.SelectedValue,CType(Container.DataItem, System.Data.DataRowView)("RentalFeeAmount"),CType(Container.DataItem, System.Data.DataRowView)("DepositAmount"),CType(Container.DataItem, System.Data.DataRowView)("CancellationAmount"),CType(Container.DataItem, System.Data.DataRowView)("DepositAmount"),CType(Container.DataItem, System.Data.DataRowView)("ExtraHourAmount"),CType(Container.DataItem, System.Data.DataRowView)("AssetName"), hf1.Value) %>' />

Open in new window


Those values are grabbed and declared as thus:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        Dim intRentalFee As Decimal
        Dim intExtraHourFee As Decimal
        Dim intCancelFee As Decimal
        Dim intKeyDeposit As Decimal
        Dim intHours As Integer = 0

        ' txtsitecode.Text = Request.QueryString("id").ToString
        txtParticipantNumber.Text = Request.QueryString("groupsize")
        'txtfeeAmount.Text = Request.QueryString("facilityfees")
        txtfacilty.Text = Request.QueryString("facility")
        rentalfeeHide.Text = Convert.ToDecimal(Request.QueryString("facilityfees"))
        extrahrfeeHide.Text = Convert.ToDecimal(Request.QueryString("extrahour"))
        depositfeeHide.Text = Convert.ToDecimal(Request.QueryString("depoitAmt"))
        cancelfeeHide.Text = Convert.ToDecimal(Request.QueryString("cancelAmt"))
        keydepositfeeHide.Text = Convert.ToDecimal(Request.QueryString("keydeptAmt"))
        intHours = Request.QueryString("hoursdiff")
        'Response.Write(intHours)
        'Response.End()
        Dim getDifference As Integer = 0
        lblhourspassedval.Text = intHours - 4
        getDifference = intHours - 4

        intRentalFee = rentalfeeHide.Text
        intRentalFee = Session("intRentalFee")
        ' extrahrfeeHide.Text = getDifference * 3
        intExtraHourFee = extrahrfeeHide.Text * getDifference

        intCancelFee = cancelfeeHide.Text
        intKeyDeposit = keydepositfeeHide.Text

        ' Dim Total As Label = DirectCast(FindControl("lb_totalbill"), Label)
        lblTotal.Text = intRentalFee + intExtraHourFee
        ' Response.Write(Total)
        '  Response.End()

        If Not IsPostBack Then
            If Session("UserEmail") Is Nothing Then
                ' Redirect user to login before doing anything else
                Response.Redirect("~/Login.aspx?redirect=requestSummary.aspx")
            End If
        End If
    End Sub

Open in new window


While here, user will be prompted for authentication if the user did not log in before getting here:

Once user is authenticated  and redirected  here, everything, as stated, is blank.

So, above code is where I would need to store the control values in session.

Can you give me an example of how to do this?

I tried this but it didn't solve  the empty values problem.

   intHours = Request.QueryString("hoursdiff")
   intHours = Session("intHours").ToString()

Open in new window


Then I try to display the value of intHours:

lblhourspassedval.Text = intHours 

Open in new window


What am I doing wrong?

Note that I only intHours just to show how I am storing the values in session.
CodeCruiserCommented:
Given that you are passing all the information in querystring to requestsummary.aspx, I think all you have to do is to change line 40 to include that query string in the redirect url
sammySeltzerAuthor Commented:
Sorry but this doesn't make much sense.
CodeCruiserCommented:
In your first code snippet, you are passing a query string to redirectsummary.aspx and i assumed you are then displaying that information on the page. Is that right?
sammySeltzerAuthor Commented:
Yes, this is correct.

Let's say there is a page1.aspx.

On this page is a link with querystring values.

A user clicks this link and is taken to requestSummary.aspx:

Those querystring values are grabbed on code behind and values displayed on the markup on that page.

Here is the codebehind again:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        Dim intRentalFee As Decimal
        Dim intExtraHourFee As Decimal
        Dim intCancelFee As Decimal
        Dim intKeyDeposit As Decimal
        Dim intHours As Integer = 0

        ' txtsitecode.Text = Request.QueryString("id").ToString
        txtParticipantNumber.Text = Request.QueryString("groupsize")
        'txtfeeAmount.Text = Request.QueryString("facilityfees")
        txtfacilty.Text = Request.QueryString("facility")
        rentalfeeHide.Text = Convert.ToDecimal(Request.QueryString("facilityfees"))
        extrahrfeeHide.Text = Convert.ToDecimal(Request.QueryString("extrahour"))
        depositfeeHide.Text = Convert.ToDecimal(Request.QueryString("depoitAmt"))
        cancelfeeHide.Text = Convert.ToDecimal(Request.QueryString("cancelAmt"))
        keydepositfeeHide.Text = Convert.ToDecimal(Request.QueryString("keydeptAmt"))
        intHours = Request.QueryString("hoursdiff")
        'Response.Write(intHours)
        'Response.End()
        Dim getDifference As Integer = 0
        lblhourspassedval.Text = intHours - 4
        getDifference = intHours - 4

        intRentalFee = rentalfeeHide.Text
        intRentalFee = Session("intRentalFee")
        ' extrahrfeeHide.Text = getDifference * 3
        intExtraHourFee = extrahrfeeHide.Text * getDifference

        intCancelFee = cancelfeeHide.Text
        intKeyDeposit = keydepositfeeHide.Text

        ' Dim Total As Label = DirectCast(FindControl("lb_totalbill"), Label)
        lblTotal.Text = intRentalFee + intExtraHourFee
        ' Response.Write(Total)
        '  Response.End()

        If Not IsPostBack Then
            If Session("UserEmail") Is Nothing Then
                ' Redirect user to login before doing anything else
                Response.Redirect("~/Login.aspx?redirect=requestSummary.aspx")
            End If
        End If
    End Sub

Open in new window


This is value is displayed on vwPersonalData of multiview control on requestSummary.aspx.

Infact, I can deal without using multiview control.

The issue here is that a user clicks that link with querystring from page1.aspx and  as stated is redirected here.

When the user clicks the Next button, the user is challenged to enter username and password with this:

        If Not IsPostBack Then
            If Session("UserEmail") Is Nothing Then
                ' Redirect user to login before doing anything else
                Response.Redirect("~/Login.aspx?redirect=requestSummary.aspx")
            End If
        End If

Open in new window


When the user is successfully authenticated, s/he is brought back to this requestSummary.aspx page.

From here, I am not sure I get how you can use another querystring to repopulate the form.

Perhaps an example?

BTW: sorry I am responding late. I have no idea you responded.

I didn't see an email of that.
CodeCruiserCommented:
Right. I don't have your code so I can only provide untested suggestions. Try change

Response.Redirect("~/Login.aspx?redirect=requestSummary.aspx")

to

Response.Redirect("~/Login.aspx?redirect=requestSummary.aspx" & request.url.query)
sammySeltzerAuthor Commented:
Ok, I got it working.

It is the way I was using session that was erasing the values upon authentication but the following worked perfectly for me.

If Not IsPostBack Then
            If Session("intHours") Is Nothing Then
                'Set the session due to querystring vlaue 
                Session("intHours") = Request.QueryString("hoursdiff")
            End If
            If Session("rentalfees") Is Nothing Then
                'Set the session due to querystring vlaue 
                Session("rentalfees") = Convert.ToDecimal(Request.QueryString("facilityfees"))
            End If
            If Session("deposits") Is Nothing Then
                'Set the session due to querystring vlaue 
                Session("deposits") = Convert.ToDecimal(Request.QueryString("depoitAmt"))
            End If
            If Session("extrahrfees") Is Nothing Then
                'Set the session due to querystring vlaue 
                Session("extrahrfees") = Convert.ToDecimal(Request.QueryString("extrahour"))
            End If
            If Session("cancelfees") Is Nothing Then
                'Set the session due to querystring vlaue 
                Session("cancelfees") = Convert.ToDecimal(Request.QueryString("cancelAmt"))
            End If
            If Session("keydeposits") Is Nothing Then
                'Set the session due to querystring vlaue 
                Session("keydeposits") = Convert.ToDecimal(Request.QueryString("keydeptAmt"))
            End If
            If Session("facilityname") Is Nothing Then
                'Set the session due to querystring vlaue 
                Session("facilityname") = Request.QueryString("facility")
            End If
            If Session("groupsizes") Is Nothing Then
                'Set the session due to querystring vlaue 
                Session("groupsizes") = Request.QueryString("groupsize")
            End If
            If Session("UserEmail") Is Nothing Then
                'Redirect user to login before doing anything else
                Response.Redirect("~/Login.aspx?redirect=requestSummary.aspx")
            End If
        End If
        lblhourspassedval.Text = Session("intHours") - 4
        rentalfeeHide.Text = Session("rentalfees")
        depositfeeHide.Text = Session("deposits")
        extrahrfeeHide.Text = Session("extrahrfees")
        cancelfeeHide.Text = Session("cancelfees")
        keydepositfeeHide.Text = Session("keydeposits")
        txtfacilty.Text = Session("facilityname")
        txtParticipantNumber.Text = Session("groupsizes")
        totExtrHrFees.Text = Session("extrahrfees") * (Session("intHours") - 4)
        lblTotal.Text = Session("rentalfees") + Session("intExtraHourFee") + (Session("extrahrfees") * (Session("intHours") - 4))
    End Sub

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sammySeltzerAuthor Commented:
Please close this question as I have solved my problem and posted the solution.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.