Murray Brown
asked on
ASP.net creating a link with a variable that can be used by ASP.net web form
Hi
I want to email an link to someone that takes them to my website and
then uses a variable that I have assigned to them.
Someone suggested a link that looks as follows.
www.yourwebsite.com/landingpage.aspx?activation_code = asdfd123dfa
How would my website make use of the code? Would activation_code be a session variable?
I want to email an link to someone that takes them to my website and
then uses a variable that I have assigned to them.
Someone suggested a link that looks as follows.
www.yourwebsite.com/landingpage.aspx?activation_code = asdfd123dfa
How would my website make use of the code? Would activation_code be a session variable?
Normally that code would be stored in a database so your server code could look it up when they go to your landing page. It would not normally be stored in a session variable because the session will most likely be expired before they come back. The link in the email could also just start a new session where that variable would not be seen for any number of reasons.
ASKER
Thanks
I still don't understand what happens in the page load when that link reaches there.
Here is a further example along the same lies that doesn't mentions but doesn't answer my question
Guid theVerificationCode;
theVerificationCode = Guid.NewGuid();
Now store this GUID value in a database column, presumably in a User-like table.
Now when you are sending the email, you can provide this verification code value as part of a URL via the query string, like this:
string theVerificationCode = GetVerificationCodeFromDat abase();
string theEmailLink = "https://www.yoursite.com/YourApp/Verify.aspx?code=" + theVerificationCode;
Finally, you will need to build logic into the Verify.aspx page that will match what was passed in the query string matches what is in the database, if they match then you can allow the user to authenticate, if not then display an error message.
I still don't understand what happens in the page load when that link reaches there.
Here is a further example along the same lies that doesn't mentions but doesn't answer my question
Guid theVerificationCode;
theVerificationCode = Guid.NewGuid();
Now store this GUID value in a database column, presumably in a User-like table.
Now when you are sending the email, you can provide this verification code value as part of a URL via the query string, like this:
string theVerificationCode = GetVerificationCodeFromDat
string theEmailLink = "https://www.yoursite.com/YourApp/Verify.aspx?code=" + theVerificationCode;
Finally, you will need to build logic into the Verify.aspx page that will match what was passed in the query string matches what is in the database, if they match then you can allow the user to authenticate, if not then display an error message.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi
Does that mean I would have page load code that looks something like:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim X As String = Request.Querystring["activ ation_code "]
End Sub
I "Identifier expected" as an error.
Sorry but still confused
Does that mean I would have page load code that looks something like:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim X As String = Request.Querystring["activ
End Sub
I "Identifier expected" as an error.
Sorry but still confused
ASKER
OK I think I am getting somewhere. Going to test the following VB.net code
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim X As String = Request.QueryString("activ ation_code ")
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim X As String = Request.QueryString("activ
End Sub
ASKER
OK got it to work. The following link works with the code proceeding it...
www.webexcel.co.za/Default.aspx?activation_code= asdfd123dfa
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim X As String = Request.QueryString("activ ation_code ")
Me.Label2.Text = X
End Sub
www.webexcel.co.za/Default.aspx?activation_code= asdfd123dfa
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim X As String = Request.QueryString("activ
Me.Label2.Text = X
End Sub
ASKER
Thanks very much for the help
You're welcome, glad to help.