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

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

  1. #1
    Hi,

    *** 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
  2. dwirch

    dwirch Well-Known Member

    Messages:
    239
    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