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.

php to asp

Discussion in 'C#' started by roice, Sep 2, 2010.

  1. #1
    Hello,
    I have code that written in PHP. Can anyone help me to translate it to ASP?
    
    $url = $_SERVER['HTTP_REFERER'];
    
    preg_match("/\&q=(.*?)\&/", $url, $matches);
    
    $str = $matches[1];
    echo "str: $str <br />";  
    PHP:
    Thank...
     
    roice, Sep 2, 2010 IP
  2. roice

    roice Peon

    Messages:
    200
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    please...?
     
    roice, Sep 6, 2010 IP
  3. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,680
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Would be much easier to say what you're trying to achieve than giving some PHP (which doesn't mean anything to me)

    Request.UrlReferrer.Query will return the the full querystring for the referer, you then just need to do a match against the string to get the value of Q
     
    AstarothSolutions, Sep 7, 2010 IP
  4. roice

    roice Peon

    Messages:
    200
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I don't think so, but lets try:

    I getting url string, for example:
    http://www.google.com/#hl=en&source=hp&q=roi&aq=f&aqi=g10&aql=&oq=&gs_rfai=&pbx=1&fp=93c3c78db929eee0
    PHP:
    How can I get into variable the string between "&q" and "&" (in this example it's: "roi"), using ASP?
     
    roice, Sep 7, 2010 IP
  5. NeoRu

    NeoRu Peon

    Messages:
    28
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Just use Request.QueryString["q"]
     
    NeoRu, Sep 7, 2010 IP
  6. roice

    roice Peon

    Messages:
    200
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Hi NeoRu,
    I'm not familiar with ASP code.
    Is it possible for you to translate the 3-4 lines that I wrote, in PHP, to ASP?
     
    roice, Sep 7, 2010 IP
  7. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,680
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I have already given the command that will bring back the querystring (hl=en&source=hp&q=roi&aq=f&aqi=g10&aql=&oq=&gs_rfai=&pbx=1&fp=93c3c78db929eee0 in your example) and therefore you need to just use regular expressions to get the Q value - see the following link http://www.regular-expressions.info/dotnet.html
     
    AstarothSolutions, Sep 8, 2010 IP
  8. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #8
    camjohnson95, Sep 14, 2010 IP
  9. prptl709

    prptl709 Guest

    Messages:
    83
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Tell me how to convert the php code into asp dot net?
     
    prptl709, Mar 1, 2011 IP
  10. miguelf

    miguelf Member

    Messages:
    98
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    48
    #10
    Using Request.QueryString is the right way to go in ASP.NET.
     
    miguelf, Apr 6, 2011 IP
  11. unknownpray

    unknownpray Active Member

    Messages:
    3,831
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    70
    #11
    unknownpray, Jul 1, 2011 IP
  12. amkeabhi123

    amkeabhi123 Member

    Messages:
    219
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    28
    #12
    you can use Repoance.Redirct(); method use the code
     
    amkeabhi123, Jul 6, 2011 IP