Response.contenttype not working ???

Discussion in 'ASP .Net' started by Adrian Turner, Oct 15, 2009.

  1. The following code just outputs to the browser, I want it to download and I
    dont understand why it doesnt work....

    Sub Page_Load(Sender As Object, E As EventArgs)
    Page.EnableViewState=False
    Response.Clear()
    Response.ContentType = "application/vnd.ms-excel"
    Response.AddHeader("Content-Disposition","attachment; filename=test.xls")
    Response.write("Adrian")
    Response.end()
    end sub

    Very annoying, should be simple. Any help would be appreciated.

    Ade
     
    Adrian Turner, Oct 15, 2009
    #1
    1. Advertising

  2. On Oct 15, 5:28 pm, Adrian Turner <> wrote:
    > The following code just outputs to the browser, I want it to download and I
    > dont understand why it doesnt work....
    >
    > Sub Page_Load(Sender As Object, E As EventArgs)
    >  Page.EnableViewState=False
    >  Response.Clear()
    >  Response.ContentType = "application/vnd.ms-excel"
    >  Response.AddHeader("Content-Disposition","attachment; filename=test.xls")
    >  Response.write("Adrian")    
    >  Response.end()
    > end sub
    >
    > Very annoying, should be simple. Any help would be appreciated.
    >
    > Ade


    For me it works. It must be a cache in your browser
     
    Alexey Smirnov, Oct 15, 2009
    #2
    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. Lone
    Replies:
    0
    Views:
    533
  2. =?Utf-8?B?bGV0dWNlIGRhbmNl?=

    why does Response.ContentType = "text/plain"; not work correctly?

    =?Utf-8?B?bGV0dWNlIGRhbmNl?=, Oct 26, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    1,180
    =?Utf-8?B?bGV0dWNlIGRhbmNl?=
    Oct 26, 2006
  3. Adrian Turner

    Response.ContentType not working ???

    Adrian Turner, Oct 15, 2009, in forum: ASP .Net
    Replies:
    7
    Views:
    1,761
    Andrew Morton
    Oct 16, 2009
  4. John Smith

    ASP Not Respecting Response.ContentType

    John Smith, May 16, 2004, in forum: ASP General
    Replies:
    4
    Views:
    120
    John Smith
    May 18, 2004
  5. Katie
    Replies:
    8
    Views:
    284
    Anthony Jones
    Aug 17, 2006
Loading...

Share This Page