Hi problem with response.writefile option

Last post 01-26-2007 7:59 AM by Haissam. 5 replies.

Sort Posts:

  • Hi problem with response.writefile option

    01-26-2007, 1:41 AM
    • Member
      21 point Member
    • vishwanatha
    • Member since 10-30-2006, 9:24 AM
    • Posts 126

    Hi,

    if (System.IO.File.Exists(outputFilenameSCMS))

    {

    Response.AddHeader("Content-Disposition", "attachment; filename= " + filename1 + "");

    Response.WriteFile(outputFilenameSCMS, true);

    }  I have written the above code in one function for button click event, outputFilenameSCMS contains valid filename present in the machine. The problem is that when i execute the above function the response is generating in the same page. I am having requirement to generate the response in some other page, something like this i have tried for..

    if (System.IO.File.Exists(outputFilenameSCMS))

    {

    Response.Redirect(

    "Overview.aspx?UserID=" + UserID + "&FileName1=" + outputFilenameSCMS);  

    }

    Overview pages page load event, i am actually generating the response as the above by fetching the filename from the query string. But problem is that it is generating the response in the same page i.e., not in the overview page, UserID also contains valid user name. How to solve this issue. Please help

    Thanks

    Vishwanath

  • Re: Hi problem with response.writefile option

    01-26-2007, 6:34 AM
    • All-Star
      37,391 point All-Star
    • Haissam
    • Member since 10-05-2006, 2:25 AM
    • Beirut - Lebanon
    • Posts 5,632

    onclick of you button write

    if (System.IO.File.Exists(outputFilenameSCMS))

    {

    Response.Redirect(

    "Overview.aspx?UserID=" + UserID + "&FileName1=" + outputFilenameSCMS);  

    }

    then on page_load of the overview page, like u were saying take the file value from the query string and

    if (System.IO.File.Exists(outputFilenameSCMS))

    {

    Response.ClearHeaders();

    Response.ClearContent();

     

    Response.AddHeader("Content-Disposition", "attachment; filename= " + filename1);

     

    Response.WriteFile(outputFilenameSCMS, true);

    Response.End();

    HC

    Haissam Abdul Malak
    MCAD.NET
    | Blog |
  • Re: Hi problem with response.writefile option

    01-26-2007, 7:25 AM
    • Member
      21 point Member
    • vishwanatha
    • Member since 10-30-2006, 9:24 AM
    • Posts 126

    Hi,

     I can only able download the file from my original page but overview is not displaying, what is the problem.

    Thanks

    Vishwanath

  • Re: Hi problem with response.writefile option

    01-26-2007, 7:38 AM
    Answer
    • All-Star
      37,391 point All-Star
    • Haissam
    • Member since 10-05-2006, 2:25 AM
    • Beirut - Lebanon
    • Posts 5,632

    check if the overview name is the exact name of the webpage, consider c# is a case sensitive language

    check if the overview is in the file application root folder.

    if it still not working just for testing use Response.Redirect("Overview.aspx"); without the query string parameters to see if they are doing a problem

    HC

    Haissam Abdul Malak
    MCAD.NET
    | Blog |
  • Re: Hi problem with response.writefile option

    01-26-2007, 7:50 AM
    • Member
      21 point Member
    • vishwanatha
    • Member since 10-30-2006, 9:24 AM
    • Posts 126

    Hi,

    It is actually working, the code is executing in the Overview page but the problem is that Overview page is not displaying only the code in that is executing. how to do it.

    Thanks

  • Re: Hi problem with response.writefile option

    01-26-2007, 7:59 AM
    • All-Star
      37,391 point All-Star
    • Haissam
    • Member since 10-05-2006, 2:25 AM
    • Beirut - Lebanon
    • Posts 5,632

    if i understood u correctly you need to clear ur responses on the overview page

    use the below 3 lines of code to clear the response.

    Response.ClearHeaders();

    Response.ClearContent();

    Response.Clear();

     if i didnt understand you explain in a clearly way

    HC

    Haissam Abdul Malak
    MCAD.NET
    | Blog |
Page 1 of 1 (6 items)