Getting the URL of the origin / referrer for user registration
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I have a piece of code that I've tested for a simple user registration code:
ReferrerURL = Request.UrlReferrer.AbsoluteUri
This property is set for user when he registers onto the website.
For example if user clicked onto the site via some ad, I'd like to get the origin site from where he came from.
With this piece of code I'm only getting the URL of my own site which looks like:
example.com/Registration
Regardless where the user came from... Is there any other way to fetch that information from where the user originally came (if it is available) - if not then just simply leave this field as null...
[ValidateAntiForgeryToken]
public async Task<ActionResult> DoRegister(UserRegistrationViewModel model)
var user = new Users()
FirstName = model.FirstName,
LastName = model.LastName,
Email = model.Email,
CountryId = 230,
Active = false,
PasswordSalt = salt,
PasswordHash = PasswordHelper.CreatePasswordHash(model.Password, salt),
GUID = _guid,
HasSpecialSubscription = false,
TotalScans = 0,
IsFreeTrialExpired = false,
DateOfRegistration = DateTime.Now,
ReferrerId = referrerId,
AffiliatePct = 0.15,
Cycles = 3,
ReferrerURL = Request.UrlReferrer.AbsoluteUri
;
c# asp.net-mvc referrer
add a comment |
I have a piece of code that I've tested for a simple user registration code:
ReferrerURL = Request.UrlReferrer.AbsoluteUri
This property is set for user when he registers onto the website.
For example if user clicked onto the site via some ad, I'd like to get the origin site from where he came from.
With this piece of code I'm only getting the URL of my own site which looks like:
example.com/Registration
Regardless where the user came from... Is there any other way to fetch that information from where the user originally came (if it is available) - if not then just simply leave this field as null...
[ValidateAntiForgeryToken]
public async Task<ActionResult> DoRegister(UserRegistrationViewModel model)
var user = new Users()
FirstName = model.FirstName,
LastName = model.LastName,
Email = model.Email,
CountryId = 230,
Active = false,
PasswordSalt = salt,
PasswordHash = PasswordHelper.CreatePasswordHash(model.Password, salt),
GUID = _guid,
HasSpecialSubscription = false,
TotalScans = 0,
IsFreeTrialExpired = false,
DateOfRegistration = DateTime.Now,
ReferrerId = referrerId,
AffiliatePct = 0.15,
Cycles = 3,
ReferrerURL = Request.UrlReferrer.AbsoluteUri
;
c# asp.net-mvc referrer
I've undone the close vote, you may want to remove those comments
– Camilo Terevinto
Nov 14 '18 at 11:34
1
I'm pretty sure you should be getting the Referrer when the user GETs the Register page, the POST should be from your own site, always.
– Camilo Terevinto
Nov 14 '18 at 11:35
@CamiloTerevinto could you please clarify it to me a little bit more? To make the action as GET or ? Should I be getting the URL referrer from origin site via Request.UrlReferrer.AbsoluteUri property?
– User987
Nov 14 '18 at 11:42
@User987, while you making your post request from view then just set yourReferrerURL
todocument.referrer;
and then send it to controller's method. you will get original referrer
– er-sho
Nov 14 '18 at 11:43
I'm assuming your ad leads to a registration page in your website (as it should). If that's correct, you should get the referrer when you load the registration page, either from c# as you are doing or as @ershoaib mentioned
– Camilo Terevinto
Nov 14 '18 at 11:44
add a comment |
I have a piece of code that I've tested for a simple user registration code:
ReferrerURL = Request.UrlReferrer.AbsoluteUri
This property is set for user when he registers onto the website.
For example if user clicked onto the site via some ad, I'd like to get the origin site from where he came from.
With this piece of code I'm only getting the URL of my own site which looks like:
example.com/Registration
Regardless where the user came from... Is there any other way to fetch that information from where the user originally came (if it is available) - if not then just simply leave this field as null...
[ValidateAntiForgeryToken]
public async Task<ActionResult> DoRegister(UserRegistrationViewModel model)
var user = new Users()
FirstName = model.FirstName,
LastName = model.LastName,
Email = model.Email,
CountryId = 230,
Active = false,
PasswordSalt = salt,
PasswordHash = PasswordHelper.CreatePasswordHash(model.Password, salt),
GUID = _guid,
HasSpecialSubscription = false,
TotalScans = 0,
IsFreeTrialExpired = false,
DateOfRegistration = DateTime.Now,
ReferrerId = referrerId,
AffiliatePct = 0.15,
Cycles = 3,
ReferrerURL = Request.UrlReferrer.AbsoluteUri
;
c# asp.net-mvc referrer
I have a piece of code that I've tested for a simple user registration code:
ReferrerURL = Request.UrlReferrer.AbsoluteUri
This property is set for user when he registers onto the website.
For example if user clicked onto the site via some ad, I'd like to get the origin site from where he came from.
With this piece of code I'm only getting the URL of my own site which looks like:
example.com/Registration
Regardless where the user came from... Is there any other way to fetch that information from where the user originally came (if it is available) - if not then just simply leave this field as null...
[ValidateAntiForgeryToken]
public async Task<ActionResult> DoRegister(UserRegistrationViewModel model)
var user = new Users()
FirstName = model.FirstName,
LastName = model.LastName,
Email = model.Email,
CountryId = 230,
Active = false,
PasswordSalt = salt,
PasswordHash = PasswordHelper.CreatePasswordHash(model.Password, salt),
GUID = _guid,
HasSpecialSubscription = false,
TotalScans = 0,
IsFreeTrialExpired = false,
DateOfRegistration = DateTime.Now,
ReferrerId = referrerId,
AffiliatePct = 0.15,
Cycles = 3,
ReferrerURL = Request.UrlReferrer.AbsoluteUri
;
c# asp.net-mvc referrer
c# asp.net-mvc referrer
edited Nov 14 '18 at 11:34
Camilo Terevinto
20k64070
20k64070
asked Nov 14 '18 at 11:24
User987User987
1,40732149
1,40732149
I've undone the close vote, you may want to remove those comments
– Camilo Terevinto
Nov 14 '18 at 11:34
1
I'm pretty sure you should be getting the Referrer when the user GETs the Register page, the POST should be from your own site, always.
– Camilo Terevinto
Nov 14 '18 at 11:35
@CamiloTerevinto could you please clarify it to me a little bit more? To make the action as GET or ? Should I be getting the URL referrer from origin site via Request.UrlReferrer.AbsoluteUri property?
– User987
Nov 14 '18 at 11:42
@User987, while you making your post request from view then just set yourReferrerURL
todocument.referrer;
and then send it to controller's method. you will get original referrer
– er-sho
Nov 14 '18 at 11:43
I'm assuming your ad leads to a registration page in your website (as it should). If that's correct, you should get the referrer when you load the registration page, either from c# as you are doing or as @ershoaib mentioned
– Camilo Terevinto
Nov 14 '18 at 11:44
add a comment |
I've undone the close vote, you may want to remove those comments
– Camilo Terevinto
Nov 14 '18 at 11:34
1
I'm pretty sure you should be getting the Referrer when the user GETs the Register page, the POST should be from your own site, always.
– Camilo Terevinto
Nov 14 '18 at 11:35
@CamiloTerevinto could you please clarify it to me a little bit more? To make the action as GET or ? Should I be getting the URL referrer from origin site via Request.UrlReferrer.AbsoluteUri property?
– User987
Nov 14 '18 at 11:42
@User987, while you making your post request from view then just set yourReferrerURL
todocument.referrer;
and then send it to controller's method. you will get original referrer
– er-sho
Nov 14 '18 at 11:43
I'm assuming your ad leads to a registration page in your website (as it should). If that's correct, you should get the referrer when you load the registration page, either from c# as you are doing or as @ershoaib mentioned
– Camilo Terevinto
Nov 14 '18 at 11:44
I've undone the close vote, you may want to remove those comments
– Camilo Terevinto
Nov 14 '18 at 11:34
I've undone the close vote, you may want to remove those comments
– Camilo Terevinto
Nov 14 '18 at 11:34
1
1
I'm pretty sure you should be getting the Referrer when the user GETs the Register page, the POST should be from your own site, always.
– Camilo Terevinto
Nov 14 '18 at 11:35
I'm pretty sure you should be getting the Referrer when the user GETs the Register page, the POST should be from your own site, always.
– Camilo Terevinto
Nov 14 '18 at 11:35
@CamiloTerevinto could you please clarify it to me a little bit more? To make the action as GET or ? Should I be getting the URL referrer from origin site via Request.UrlReferrer.AbsoluteUri property?
– User987
Nov 14 '18 at 11:42
@CamiloTerevinto could you please clarify it to me a little bit more? To make the action as GET or ? Should I be getting the URL referrer from origin site via Request.UrlReferrer.AbsoluteUri property?
– User987
Nov 14 '18 at 11:42
@User987, while you making your post request from view then just set your
ReferrerURL
to document.referrer;
and then send it to controller's method. you will get original referrer– er-sho
Nov 14 '18 at 11:43
@User987, while you making your post request from view then just set your
ReferrerURL
to document.referrer;
and then send it to controller's method. you will get original referrer– er-sho
Nov 14 '18 at 11:43
I'm assuming your ad leads to a registration page in your website (as it should). If that's correct, you should get the referrer when you load the registration page, either from c# as you are doing or as @ershoaib mentioned
– Camilo Terevinto
Nov 14 '18 at 11:44
I'm assuming your ad leads to a registration page in your website (as it should). If that's correct, you should get the referrer when you load the registration page, either from c# as you are doing or as @ershoaib mentioned
– Camilo Terevinto
Nov 14 '18 at 11:44
add a comment |
1 Answer
1
active
oldest
votes
A referrer is a header sent by browsers when the user navigates to another page, so the target site knows the originating site - if a browser is configured to send it (privacy settings or plugins may strip the header) and if the sites use the same scheme (referrers aren't sent when transferring from http to https or vice versa).
But every click resets the referrer to the current page. So if your users flow like this:
External Site -> Registration Page -> Registration POST Handler
Then in the last one, the referrer will be your registration page, not the external site's address.
So you need to save the referrer in the registration page, and forward it to your POST action. You could do so in a hidden form field, or by storing it in the session, or in a cookie. All approaches have their pros and cons.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53299094%2fgetting-the-url-of-the-origin-referrer-for-user-registration%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
A referrer is a header sent by browsers when the user navigates to another page, so the target site knows the originating site - if a browser is configured to send it (privacy settings or plugins may strip the header) and if the sites use the same scheme (referrers aren't sent when transferring from http to https or vice versa).
But every click resets the referrer to the current page. So if your users flow like this:
External Site -> Registration Page -> Registration POST Handler
Then in the last one, the referrer will be your registration page, not the external site's address.
So you need to save the referrer in the registration page, and forward it to your POST action. You could do so in a hidden form field, or by storing it in the session, or in a cookie. All approaches have their pros and cons.
add a comment |
A referrer is a header sent by browsers when the user navigates to another page, so the target site knows the originating site - if a browser is configured to send it (privacy settings or plugins may strip the header) and if the sites use the same scheme (referrers aren't sent when transferring from http to https or vice versa).
But every click resets the referrer to the current page. So if your users flow like this:
External Site -> Registration Page -> Registration POST Handler
Then in the last one, the referrer will be your registration page, not the external site's address.
So you need to save the referrer in the registration page, and forward it to your POST action. You could do so in a hidden form field, or by storing it in the session, or in a cookie. All approaches have their pros and cons.
add a comment |
A referrer is a header sent by browsers when the user navigates to another page, so the target site knows the originating site - if a browser is configured to send it (privacy settings or plugins may strip the header) and if the sites use the same scheme (referrers aren't sent when transferring from http to https or vice versa).
But every click resets the referrer to the current page. So if your users flow like this:
External Site -> Registration Page -> Registration POST Handler
Then in the last one, the referrer will be your registration page, not the external site's address.
So you need to save the referrer in the registration page, and forward it to your POST action. You could do so in a hidden form field, or by storing it in the session, or in a cookie. All approaches have their pros and cons.
A referrer is a header sent by browsers when the user navigates to another page, so the target site knows the originating site - if a browser is configured to send it (privacy settings or plugins may strip the header) and if the sites use the same scheme (referrers aren't sent when transferring from http to https or vice versa).
But every click resets the referrer to the current page. So if your users flow like this:
External Site -> Registration Page -> Registration POST Handler
Then in the last one, the referrer will be your registration page, not the external site's address.
So you need to save the referrer in the registration page, and forward it to your POST action. You could do so in a hidden form field, or by storing it in the session, or in a cookie. All approaches have their pros and cons.
answered Nov 14 '18 at 11:45
CodeCasterCodeCaster
110k18149202
110k18149202
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53299094%2fgetting-the-url-of-the-origin-referrer-for-user-registration%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I've undone the close vote, you may want to remove those comments
– Camilo Terevinto
Nov 14 '18 at 11:34
1
I'm pretty sure you should be getting the Referrer when the user GETs the Register page, the POST should be from your own site, always.
– Camilo Terevinto
Nov 14 '18 at 11:35
@CamiloTerevinto could you please clarify it to me a little bit more? To make the action as GET or ? Should I be getting the URL referrer from origin site via Request.UrlReferrer.AbsoluteUri property?
– User987
Nov 14 '18 at 11:42
@User987, while you making your post request from view then just set your
ReferrerURL
todocument.referrer;
and then send it to controller's method. you will get original referrer– er-sho
Nov 14 '18 at 11:43
I'm assuming your ad leads to a registration page in your website (as it should). If that's correct, you should get the referrer when you load the registration page, either from c# as you are doing or as @ershoaib mentioned
– Camilo Terevinto
Nov 14 '18 at 11:44