Click here to Skip to main content
15,881,381 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello friends, I have been having a little challenge trying to create referral link for my website.
I want to have something like "www.mysitename.com/?ref=username" but my challenge is

1. How can I generate the referral url
2. How do I make it so that when new user use referral url he will be redirected to registration page to signup under the referral url.

any idea on how I can get this done will be welcome.

What I have tried:

Had no clear idea, I need help, I am still new in C#, I have not encountered that before.
Posted
Updated 31-Jul-18 9:05am

1 solution

Quote:
1. How can I generate the referral url


The example you provided uses QueryString to pass value. The stuff after the ? symbol in the URL is the query string where ref is the key and username is the value.

Quote:
2. How do I make it so that when new user use referral url he will be redirected to registration page to signup under the referral url.


You would simply use the Request object to get the value from the QueryString. For example: Request.QueryString["key"]

A quick example based on your need would be:

C#
if(Request.QueryString["ref"] != null)
{
     //redirect to the sign-up page here
     //for ASP.NET WebForms you can do:

     Response.Redirect("~/Signup.aspx");

}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900