0

Hi i am developing a website to downlod softwares online.From general page of softwares user is allowed to download software after login or register.after login it must be go to user panel's main download page with taking id of software on which a person has clicked..i code below at login page. "sid" is id of software and "tid" is template id..

 Protected Sub btnlogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnlogin.Click
        adp = New SqlDataAdapter("select * from User_details where Email_id='" & TextBox1.Text.ToString() & "' and Password='" & TextBox2.Text.ToString() & "' ", constr)
        dset = New DataSet
        dset.Clear()
        adp.Fill(dset)
        Dim sstr As String
        Dim tstr As String
        Dim type As String = "1"



        Try
            sstr = Request.QueryString.Item("sid").ToString()
            type = "soft"

        Catch ex As Exception

        End Try

        Try
            tstr = Request.QueryString.Item("tid").ToString()
            type = "temp"
        Catch ex As Exception

        End Try


        If dset.Tables(0).Rows.Count > 0 Then
            Session.Add("user_loged", "true")
            Session.Add("user_name", dset.Tables(0).Rows(0).Item(1).ToString)
            Session.Add("user_id", dset.Tables(0).Rows(0).Item(0).ToString)
            Try


                If Request.QueryString.Item("q").ToString() <> 1 Then

                    Response.Redirect("AdminPanel/Profile.aspx")
                Else
                    If type = "soft" Then
                        Dim id As Integer
                        id = Integer.Parse(Request.QueryString.Item("sid").ToString())
                        Response.Redirect("Downloadmain.aspx?sid=" & Integer.Parse(Request.QueryString.Item("sid").ToString()) & "")
                    ElseIf type = "temp" Then
                        Response.Redirect("Templatemain.aspx?sid=" & Integer.Parse(Request.QueryString.Item("tid").ToString()) & "")
                    Else
                        Response.Redirect("AdminPanel/Profile.aspx")

                    End If
                End If

            Catch ex As Exception

            End Try

        Else
            Session.Add("user_loged", "false")
            ' MsgBox("Invalid UserName or Password")
            'Response.Redirect("Login.aspx?error=Invalid password or user name")
            Label1.Visible = True
            Label1.Text = "Invalid UserName or Password"
            Label1.ForeColor = Drawing.Color.Red

        End If
    End Sub
2
Contributors
1
Reply
7
Views
4 Years
Discussion Span
Last Post by hometownnerd
0

Not sure what you are looking for exactly, is something going wrong with your code now? I see the redirects, I also see that you are doing some conversion on the querystrings, wouldn't simply Request.QueryString("sid") work? or are you really interested in going through the conversion to integer? I would go with

Response.Redirect("Downloadmain.aspx?sid=" & Request.QueryString("sid"))

That way it does not fail for miscelaneous reasons. Let us know what you are looking for exactly and someone may be able to help a bit.
Have fun,
Larry

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.