Problem with double database writes when using asp in an IFrame.

Discussion in 'C#' started by Absilon, Jan 28, 2009.

  1. #1
    I am trying to write an asp banner exchange script and am having a problem with double database writes for each ad view when using an iframe on partner sites to show the banner.

    I tried using the following IFrame code to display the banner:

    <iframe rel="nofollow" src="http://www.domain.com/display.asp?s=12345" marginwidth="0" marginheight="0" height="100" width="100" scrolling="no" border="0" frameborder="0" style="margin: 0px" name="AB'+rand+'"></iframe>

    The problem with this is that on the page display.asp when I write to the database to record information about the ad view it always writes two entries for each one ad view. I assume this has something to do with the iframe since when I go to the page directly it only writes the data once.

    Is there a way to get this working or do I have to do something other than using an iframe?

    I have seen other banner exchange sites using a partner code like this:

    <script type="text/javascript" src="http://www.website.com/display.asp?s=12345"></script>

    But I have no idea what to put into display.asp to get it to display the banner.

    Any help at all would be greatly appreciated.
     
    Absilon, Jan 28, 2009 IP
  2. tihomir_wwf

    tihomir_wwf Active Member

    Messages:
    363
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    73
    #2
    I'm not sure if I understand correct the problem, Could you paste your code-behind code of the page.

    It seems that check for IsPostBack should be added
     
    tihomir_wwf, Jan 29, 2009 IP
  3. Absilon

    Absilon Peon

    Messages:
    158
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    There is no code-behind code as this is not .net it is classic ASP.

    The only thing in my code on display.asp is this:
    REMOTE_ADDR = Request.ServerVariables("REMOTE_ADDR")
    REMOTE_HOST = Request.ServerVariables("REMOTE_HOST")
    REMOTE_USER = Request.ServerVariables("REMOTE_USER")
    HTTP_REFERER = Request.ServerVariables("HTTP_REFERER")
    HTTP_USER_AGENT = Request.ServerVariables("HTTP_USER_AGENT")
    REQUEST_METHOD = Request.ServerVariables("REQUEST_METHOD")
    SERVER_NAME = Request.ServerVariables("SERVER_NAME")

    set LoRS_BannerViews = server.createobject("adodb.recordset")
    sql = "select * from BannerViews"
    LoRS_BannerViews.open sql, Conn, 1, 3
    LoRS_BannerViews.addnew
    LoRS_BannerViews("REMOTE_ADDR") = REMOTE_ADDR
    LoRS_BannerViews("REMOTE_HOST") = REMOTE_HOST
    LoRS_BannerViews("REMOTE_USER") = REMOTE_USER
    LoRS_BannerViews("HTTP_REFERER") = HTTP_REFERER
    LoRS_BannerViews("HTTP_USER_AGENT") = HTTP_USER_AGENT
    LoRS_BannerViews("REQUEST_METHOD") = REQUEST_METHOD
    LoRS_BannerViews("SERVER_NAME") = SERVER_NAME
    LoRS_BannerViews.update
    Set LoRS_BannerViews = Nothing

    There is no problem with this code. The problem is that for each banner view on the partners website that uses my Iframe banner code to display the display.asp page the above code is executed twice. So each banner view is recorded as two banner views.
     
    Absilon, Jan 29, 2009 IP