473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Client and Office from asp.net

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
Jun 27 '08 #1
7 1049
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" <dl*****@lifetimeinc.comwrote in message
news:ef**************@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

Jun 27 '08 #2
George,
Thank you for that info. However, it still does not open in the native
program (Microsoft Word, Microsoft Excel, etc.). It opens it in the browser
where it cannot be edited.

David
"George Ter-Saakov" <gt****@cardone.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
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" <dl*****@lifetimeinc.comwrote in message
news:ef**************@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


Jun 27 '08 #3
Show me the code.....

PS: There was a bug in IE 5.01 and it ignored the "attachment" .... But I
hope it's not the case here. Since we already have IE 7.

George.
"David C" <dl*****@lifetimeinc.comwrote in message
news:u4**************@TK2MSFTNGP06.phx.gbl...
George,
Thank you for that info. However, it still does not open in the native
program (Microsoft Word, Microsoft Excel, etc.). It opens it in the
browser where it cannot be edited.

David
"George Ter-Saakov" <gt****@cardone.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>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" <dl*****@lifetimeinc.comwrote in message
news:ef**************@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



Jun 27 '08 #4
Nevermind. The problem was that I did not need "\" before and after
filename as I am using VB. When I took them off, it appears to work fine.
Thanks.

David
"George Ter-Saakov" <gt****@cardone.comwrote in message
news:uT**************@TK2MSFTNGP04.phx.gbl...
Show me the code.....

PS: There was a bug in IE 5.01 and it ignored the "attachment" .... But I
hope it's not the case here. Since we already have IE 7.

George.
"David C" <dl*****@lifetimeinc.comwrote in message
news:u4**************@TK2MSFTNGP06.phx.gbl...
>George,
Thank you for that info. However, it still does not open in the native
program (Microsoft Word, Microsoft Excel, etc.). It opens it in the
browser where it cannot be edited.

David
"George Ter-Saakov" <gt****@cardone.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>>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" <dl*****@lifetimeinc.comwrote in message
news:ef**************@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



Jun 27 '08 #5
George,
I did find a problem. Office 2007 opens a document from a previous version
of Office with a different name (e.g. it adds [1] to the name). For example,
if I open test.doc on a machine with office 2007 it opens it as test[1].doc
in a temporary directory. When it opens a file like test.docx it opens the
original. Is there any way to handle this? Thanks.

David
"George Ter-Saakov" <gt****@cardone.comwrote in message
news:uT**************@TK2MSFTNGP04.phx.gbl...
Show me the code.....

PS: There was a bug in IE 5.01 and it ignored the "attachment" .... But I
hope it's not the case here. Since we already have IE 7.

George.
"David C" <dl*****@lifetimeinc.comwrote in message
news:u4**************@TK2MSFTNGP06.phx.gbl...
>George,
Thank you for that info. However, it still does not open in the native
program (Microsoft Word, Microsoft Excel, etc.). It opens it in the
browser where it cannot be edited.

David
"George Ter-Saakov" <gt****@cardone.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>>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" <dl*****@lifetimeinc.comwrote in message
news:ef**************@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



Jun 27 '08 #6
Doubt that you can do anything here...
this is how Open/Save dialog works.....

If you choose "Save" then you can save it with the name you specified in
your "Content-Disposition" header.
If you choose "Open" IE will actually save the file into "TEMP" folder and
then open application (as if you double clicked on file). But if file with
that name already exists IE quietly appends [1] (or [2],...) to the name.

I do not know how to change that behavior andf most likely you can not....
George.

"David C" <dl*****@lifetimeinc.comwrote in message
news:OJ**************@TK2MSFTNGP06.phx.gbl...
George,
I did find a problem. Office 2007 opens a document from a previous
version of Office with a different name (e.g. it adds [1] to the name).
For example, if I open test.doc on a machine with office 2007 it opens it
as test[1].doc in a temporary directory. When it opens a file like
test.docx it opens the original. Is there any way to handle this?
Thanks.

David
"George Ter-Saakov" <gt****@cardone.comwrote in message
news:uT**************@TK2MSFTNGP04.phx.gbl...
>Show me the code.....

PS: There was a bug in IE 5.01 and it ignored the "attachment" .... But I
hope it's not the case here. Since we already have IE 7.

George.
"David C" <dl*****@lifetimeinc.comwrote in message
news:u4**************@TK2MSFTNGP06.phx.gbl...
>>George,
Thank you for that info. However, it still does not open in the native
program (Microsoft Word, Microsoft Excel, etc.). It opens it in the
browser where it cannot be edited.

David
"George Ter-Saakov" <gt****@cardone.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl.. .
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" <dl*****@lifetimeinc.comwrote in message
news:ef**************@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
>




Jun 27 '08 #7
I think if you set the content-disposition to inline and the content-type to
the proper mime type and then stream it down with Response.WriteFile or
BinaryWrite it will open automatically on it's application when you click
the link on a webpage.

As for using ActiveX, the process would be the same for any type of file
since you're just embedding the application on the webpage and letting it do
the rest.
"David C" <dl*****@lifetimeinc.comwrote in message
news:ef**************@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

Jun 27 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Chris | last post by:
Hi, - How can I open an existing word document from a C#-client and manipulate that document from within the C#-client ? - How can I open an excel document that is embedded in a word-document...
10
by: Woody Splawn | last post by:
I have been developing a ClientServer application on one machine at my office but the time has come to transfer it to the customer. The customer is running a Windows 2000 local area network. I...
0
by: Marco Singer | last post by:
Hi all, I want to create an Office automation client for Office 97 (and newer) which should automate Access, Excel and Word. On my developer computer I have Office XP installed. In KB244167...
2
by: NRakhesh | last post by:
I have to submit a project as a part of my final year project. I consulted various domains and finally decided to implement a work on delevoping a system for transcription work based company. ...
5
by: B1ackwater | last post by:
We've fooled around with Access a bit, but only using the single-user store-bought version. It seems to be a good database - versatile and infinitely programmable - and can apparently be used as a...
11
by: nn0410 | last post by:
I am about to deliver my first Access application to a client and am trying to do things "right" now, so as to make future maintenance as painless as possible for the client and myself. Following...
11
by: Wayne | last post by:
I am a one man enterprise and have been asked by a prospective client what happens to their database regarding ongoing changes etc if I get hit by a bus. Obviously my databases are distributed...
13
by: John Kotuby | last post by:
I am expecting the answer to be, "of course not" or " are you kidding?", but maybe (hopefully) I am wrong and somebody can point me to an ingenious example of how the impossible just takes a little...
8
by: =?Utf-8?B?QmFkaXM=?= | last post by:
I have tried a server-side automation and it's giving me problems that I couldn't solve.. Now, I'm switching to client side automation and I was following this example:...
11
by: Bill Davy | last post by:
I am trying to edit Contacts in Outlook. This is so I can transfer numbers from my address book which is an Excel spreadsheet to my mobile phone. I came across the following snippet of code which...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.