Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Can I change the response URL to http://server/page.XLS instead of http://server/page.ASPX ?

Reply
Thread Tools

Can I change the response URL to http://server/page.XLS instead of http://server/page.ASPX ?

 
 
guillermojco@gmail.com
Guest
Posts: n/a
 
      04-24-2007
Hi,

I've got an ASP.NET page that returns XLS, DOC, PDF and other files
from binary fields in a database.

The problem is that MS-Excel 2007 shows a security warning when trying
to open the file because its name is page.ASPX instead of page.XLS
(the file opens properly when this warning is accepted by the user).

I thing the problem would solve if I can change the response URL from
"page.ASPX" to "page.XLS"

I don't want to use redirection because I don't have a real XLS file
but a byte array.

I've been unable to find this in the "Response" object documentation,
I wonder if it is possible.

Also, I don't have this problem with DOC or PDF files, they're opened
properly without any warnings.

Thanks!

Guillermo.

 
Reply With Quote
 
 
 
 
Ray Costanzo
Guest
Posts: n/a
 
      04-24-2007
This works for me:

protected void Page_Load(object sender, EventArgs e)
{
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader ("Content-Disposition", "inline;
filename=somefile.xls");
}

Ray at work

<> wrote in message
news: oups.com...
> Hi,
>
> I've got an ASP.NET page that returns XLS, DOC, PDF and other files
> from binary fields in a database.
>
> The problem is that MS-Excel 2007 shows a security warning when trying
> to open the file because its name is page.ASPX instead of page.XLS
> (the file opens properly when this warning is accepted by the user).
>
> I thing the problem would solve if I can change the response URL from
> "page.ASPX" to "page.XLS"
>
> I don't want to use redirection because I don't have a real XLS file
> but a byte array.
>
> I've been unable to find this in the "Response" object documentation,
> I wonder if it is possible.
>
> Also, I don't have this problem with DOC or PDF files, they're opened
> properly without any warnings.
>
> Thanks!
>
> Guillermo.
>


 
Reply With Quote
 
 
 
 
Guillermo
Guest
Posts: n/a
 
      04-26-2007
On 24 abr, 19:30, "Ray Costanzo" <my first name at lane 34 dot
commercial> wrote:
> This works for me:
>
> protected void Page_Load(object sender, EventArgs e)
> {
> Response.ContentType = "application/vnd.ms-excel";
> Response.AddHeader ("Content-Disposition", "inline;
> filename=somefile.xls");
> }
>
> Ray at work


Thank you very much, but this didn't solve my problem (I'm using
Office 2007, this could be the problem, I'll try Office 2003).

Your code works fine to change the file name from "page.aspx" to
"somefile.xls" in Internet Explorer 7 dialog box. But when I choose
"save", the default file name appears as "page.xls" instead of
"somefile.xls".

Also, when I choose "open", Excel 2007 receives a "page.aspx" file so
it still gives a warning. When I go on, the workbook is properly
displayed but title in Excel windows remains "page.aspx".

It's the same with DOC files, Word 2007 still shows "page.aspx" as
window title, but no warnings are displayed.

Thank you again.

 
Reply With Quote
 
Guillermo
Guest
Posts: n/a
 
      04-26-2007
On 24 abr, 19:30, "Ray Costanzo" <my first name at lane 34 dot
commercial> wrote:
> This works for me:
>
> protected void Page_Load(object sender, EventArgs e)
> {
> Response.ContentType = "application/vnd.ms-excel";
> Response.AddHeader ("Content-Disposition", "inline;
> filename=somefile.xls");
> }
>
> Ray at work


My problem solved when using

Response.AddHeader ("Content-Disposition", "attachment;
filename=somefile.xls");

instead of

Response.AddHeader ("Content-Disposition", "inline;
filename=somefile.xls");

Thank you very much.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
change command to open a url instead of a user control lionel luo ASP .Net 1 05-20-2007 06:06 PM
Response.Redirect() converts relative URL to absolute URL =?Utf-8?B?UGF1bCBCb25mYW50aQ==?= ASP .Net 2 04-25-2006 01:07 AM
URL - substitution of a correct URL by a GUID like URL in favorites. Just D. ASP .Net Mobile 0 08-11-2004 04:26 PM
redirect URL's, return URL's, and URL Parameters Jon paugh ASP .Net 1 07-10-2004 05:29 AM
can i modify the content in the buffer of response(not response.buffer prep) xingye ASP General 9 04-19-2004 03:49 AM



Advertisments