1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Can someone tell me how to grab domain referred in ASP ?

Discussion in 'C#' started by yocredit, Jan 12, 2012.

  1. #1
    Hi,
    SEMrush
    *** PM OFFERS - WILL PAY ***

    Can someone tell me how to grab domain referred in ASP ?
    Mainly I done this piece of code in PHP which works well but I would like to translate this code into ASP.
    Please, could someone help me?

    
    <?php
    
    echo ('Referring domain:</br>');
    $ref = $_SERVER[SERVER_NAME]; // grab domain
    echo ($ref.'<br/>'); // show domain
    
    if ($ref == "www.domain.co.uk") { 
      echo ('This domain is correct.');
    } 
    else {
      echo ('This domain is wrong.<br/>');
      echo ('Added into HEAD section following META:<br>&lt;META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"&gt;');
      ?>
      <META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
      <?
    }
    
    ?> 
    
    Code (markup):
     
    Last edited: Jan 12, 2012
    yocredit, Jan 12, 2012 IP
    SEMrush
  2. dwirch

    dwirch Well-Known Member

    Messages:
    238
    Likes Received:
    12
    Best Answers:
    1
    Trophy Points:
    135
    #2
    The server variable "http_referer" holds the referring information. You can grab it with:

    ReferringDomain=request.servervariables("http_referer") 
    Code (markup):
    Then to check it, you might do something like this:

    If ReferringDomain="www.domain.co.uk" then
        'Correct domain
    else
        'incorrect domain
    end if
    Code (markup):
     
    dwirch, Jan 22, 2012 IP