Client and Office from asp.net

Client and Office from asp.net

am 24.04.2008 20:19:32 von David C

I have an internal asp.net 2.0 web application where we display the contents
of various files using Response.ContentType and Response.WriteFile()
settings and it works great for .doc, .xls, etc. files. Now the users want
to be able to open them in their native programs (Microsoft Word, Excel,
etc.). I have done this with ActiveX before, but the company has moved to
Office 2007 and I'm not sure the same process will work for the new docx,
xlsx, etc. files. Can anyone give me some ideas on the best way to handle
this? All users have Microsoft Office. Thanks.

David

Re: Client and Office from asp.net

am 24.04.2008 20:38:43 von George Ter-Saakov

You should add Content-Disposition to the header.
Like this Content-Disposition: attachment; filename="file.pdf"

So in C# code it's Response.AddHeader("Content-Disposition", "attachment;
filename=\"file.pdf\"");
And then do Response.WriteFile

Browser will be forced (thanks to "attachment" word) to pop up a window
offering to save file or open it in application.


George.


"David C" wrote in message
news:efUJQgjpIHA.4620@TK2MSFTNGP06.phx.gbl...
>I have an internal asp.net 2.0 web application where we display the
>contents of various files using Response.ContentType and
>Response.WriteFile() settings and it works great for .doc, .xls, etc.
>files. Now the users want to be able to open them in their native programs
>(Microsoft Word, Excel, etc.). I have done this with ActiveX before, but
>the company has moved to Office 2007 and I'm not sure the same process will
>work for the new docx, xlsx, etc. files. Can anyone give me some ideas on
>the best way to handle this? All users have Microsoft Office. Thanks.
>
> David
>