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;








-1















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
;










share|improve this question
























  • 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 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

















-1















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
;










share|improve this question
























  • 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 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













-1












-1








-1








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
;










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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'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 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'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












1 Answer
1






active

oldest

votes


















2














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.






share|improve this answer























    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
    );



    );













    draft saved

    draft discarded


















    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









    2














    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.






    share|improve this answer



























      2














      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.






      share|improve this answer

























        2












        2








        2







        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.






        share|improve this answer













        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 14 '18 at 11:45









        CodeCasterCodeCaster

        110k18149202




        110k18149202





























            draft saved

            draft discarded
















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

            Crossroads (UK TV series)

            ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế