file download in asp.net

Discussion in 'ASP .Net' started by =?Utf-8?B?dmlqYXk=?=, May 7, 2004.

  1. Hi

    I am working on a web application and in ASp.Net using C#. The requirement is to create a csv file on the server and the user should be able to save the file on his machine. I am creating a csv file on the server and throwing the contents of the csv file to the user using Response.BinaryWrite method

    It is working fine in every server except my web server (Windows 2003 server) which is in DMZ

    The problem I am facing is instead the csv file content, user is getting the html code of the page which he is accessing

    I wrote the following code im my aspx.cs fil

    long FileSize
    FileSize = sourceFile.Length
    byte[] getContent = new byte[(int)FileSize]
    sourceFile.Read(getContent, 0, (int)sourceFile.Length)
    //close the file stream
    sourceFile.Close()
    //delete the fil
    File.Delete(strFilePath)
    Response.BinaryWrite(getContent)
    Response.End(

    How can I get the csv content in the file that is being downloaded by the user

    Please help me

    Thaks and Regards
    Vija
     
    =?Utf-8?B?dmlqYXk=?=, May 7, 2004
    #1
    1. Advertising

  2. =?Utf-8?B?dmlqYXk=?=

    avnrao Guest

    it depends on how you want to show it on the browser.
    say if you want show the data in excel sheet set
    Response.ContentType = "application/vnd.ms-excel";

    Av.

    "vijay" <> wrote in message
    news:...
    > Hi,
    >
    > I am working on a web application and in ASp.Net using C#. The requirement
    > is to create a csv file on the server and the user should be able to save
    > the file on his machine. I am creating a csv file on the server and
    > throwing the contents of the csv file to the user using
    > Response.BinaryWrite method.
    >
    > It is working fine in every server except my web server (Windows 2003
    > server) which is in DMZ.
    >
    > The problem I am facing is instead the csv file content, user is getting
    > the html code of the page which he is accessing.
    >
    > I wrote the following code im my aspx.cs file
    >
    > long FileSize;
    > FileSize = sourceFile.Length;
    > byte[] getContent = new byte[(int)FileSize];
    > sourceFile.Read(getContent, 0, (int)sourceFile.Length);
    > //close the file stream.
    > sourceFile.Close();
    > //delete the file
    > File.Delete(strFilePath);
    > Response.BinaryWrite(getContent);
    > Response.End()
    >
    > How can I get the csv content in the file that is being downloaded by the
    > user.
    >
    > Please help me.
    >
    > Thaks and Regards,
    > Vijay
    >
    >
    >
    >
    >
     
    avnrao, May 7, 2004
    #2
    1. Advertising

  3. =?Utf-8?B?dmlqYXk=?=

    Guest Guest

    ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????.?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
     
    Guest, May 13, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ryan Taylor
    Replies:
    2
    Views:
    1,023
    Ryan Taylor
    Nov 10, 2004
  2. Steve C. Orr [MVP, MCSD]
    Replies:
    0
    Views:
    1,666
    Steve C. Orr [MVP, MCSD]
    Mar 7, 2005
  3. Sam --
    Replies:
    2
    Views:
    664
    Sam --
    Mar 17, 2005
  4. Rafal Majda
    Replies:
    5
    Views:
    2,453
    Rafal Majda
    Apr 18, 2005
  5. Brett  Kelly
    Replies:
    1
    Views:
    721
    Steve C. Orr [MVP, MCSD]
    Jun 16, 2006
Loading...

Share This Page