Solved

ASP.net creating a link with a variable that can be used by ASP.net web form

Posted on 2014-01-19
8
392 Views
Last Modified: 2014-01-19
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?
0
Comment
Question by:murbro
  • 5
  • 3
8 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39792491
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.
0
 

Author Comment

by:murbro
ID: 39792509
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 = GetVerificationCodeFromDatabase();
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.
0
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 39792527
Have you written any pages that accept variables from forms?  I'm not sure what the exact code needs to be for you but it used to in the format of Request.Querystring["activation_code"] for variables that are part of the URL.
0
ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 

Author Comment

by:murbro
ID: 39792536
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["activation_code"]
    End Sub

I "Identifier expected" as an error.
Sorry but still confused
0
 

Author Comment

by:murbro
ID: 39792548
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("activation_code")
    End Sub
0
 

Author Comment

by:murbro
ID: 39792560
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("activation_code")
        Me.Label2.Text = X
    End Sub
0
 

Author Closing Comment

by:murbro
ID: 39792562
Thanks very much for the help
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39792567
You're welcome, glad to help.
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB.NET 2008 (3.5 Framework) Remove all items from List 3 22
How to close an asp.net web form using C# ? 4 30
transaction in asp.net, sql server 6 33
asp.net mvc5 6 17
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question