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.

Really strange behaviour with URL generation

Discussion in 'C#' started by petemoss, Dec 1, 2007.

  1. #1
    What I am trying to do is generate a URL for downloading a document. However when the script gets the name of the file I type into the form if the filename begins with one of the following: 01- or 02- or 03- or 04- or 05- or 06- or 07- the URL comes out as:

    http://888.888.888.888/activenet/download.asp?CMD=GO&DocName=04-05 66.doc&DocPath=D:p2ActiveNETCHECKOUT-05 66.doc

    Note the square beside checkout in the URL it should come out as CHECKOUT\04-05 66.doc on the end but whenever the filename starts with lets say 03- it adds the wierd square character. If the filename begins with anything else other then the ones mentioned above even 08- it works fine.
    I blocked out the IP address with 8's

    The asp page is being hosted on Windows 2003 server and IIS 6.0. Any help would be appreciated. Below is the code



    option explicit

    dim strFileName, strFilePath, strCMD, Tmp

    strFileName = Request.Querystring("DocName")
    Tmp = server.MapPath(strFileName)
    Tmp = left(tmp,len(tmp)-len(strFileName)) & "CHECKOUT\"
    strFilePath = Tmp & strFileName
    strCMD = UCase(Request.QueryString("CMD"))

    if strCmd="GO" then
    Response.Redirect "startDownload.asp?DocName=" & strFileName & "&DocPath=" & strFilePath

    end if
    SEMrush
     
    petemoss, Dec 1, 2007 IP
    SEMrush
  2. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,681
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #2
    it has been a while but isnt \ an illegal character for a url? You would either need to construct it as a string first and then urlencode it or alternatively given it is your own site, why are you doing the mappath etc in this page and passing it to the download one? why not just pass it the doc name and allow it to do the locating?
     
    AstarothSolutions, Dec 1, 2007 IP
  3. petemoss

    petemoss Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks Asta for the quick reply, I don't know much about .asp programming, this is a vendor supplied app and they are blaming the square on an issue with the server or iis which is my responsibility. I questioned them on this because if I turn the slash the other way even / it works but then puts underscores in places of spaces. In short I was hoping to avoid getting a new server going from scratch, installing their app and proving to them its not a problem with the server. I've tried doing server.urlencode(strfilepath) after the line strFilePath = Tmp & strFileName but the square keeps appearing still.
     
    petemoss, Dec 1, 2007 IP
  4. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,681
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Do u have the url of the site to have a quick look?
     
    AstarothSolutions, Dec 2, 2007 IP
  5. urstop

    urstop Peon

    Messages:
    224
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I just put up a test page with your code on my local machine to test, and I did not find any problems, the path got transalated without that special character. Wondering what the problem could be.
     
    urstop, Dec 2, 2007 IP