Hi,
I have a form page to print on my web application(asp.net). I want to show
the page in WORD. I use that code in asp.net Page_Load event:
Response.Clear();
Response.ContentType = "application/ms-word";
Response.AddHeader("Content-Disposition", "attachment;filename=word.doc");
When I open the page in IE shows a dialog to ask whether I want to open or
save. It is ok. But when I click Open or Save button, I get an error message:
"
Internet Explorer cannot download form.aspx.
Internet Explorer was not able to open this Internet site. The requested
site is either unavailable or cannot be found. Please try again later.
"
What can I do to solve this problem?
Thanks in advance.
--
______________________________
Åženol Akbulak 10 2615
"Senol Akbulak" <se**********@newsgroup.nospam> wrote in message
news:26**********************************@microsof t.com... Hi,
I have a form page to print on my web application(asp.net). I want to show the page in WORD. I use that code in asp.net Page_Load event: Response.Clear(); Response.ContentType = "application/ms-word"; Response.AddHeader("Content-Disposition", "attachment;filename=word.doc");
When I open the page in IE shows a dialog to ask whether I want to open or save. It is ok. But when I click Open or Save button, I get an error message: " Internet Explorer cannot download form.aspx. Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later. "
What can I do to solve this problem?
hmm, it looks as if you are doing the right thing.
I presume you are streaming the binary contents of a word document directly
after setting these headers. Have you checked the document itself is being
sent correctly.
you could also try putting in a content-length header but I wouldn't have
thought this was necessary.
Thanks in advance.
-- ______________________________ Senol Akbulak
My form content is for html. Is the problem that?
Cannot Word open html content?
"Andy Fish" wrote: "Senol Akbulak" <se**********@newsgroup.nospam> wrote in message news:26**********************************@microsof t.com... Hi,
I have a form page to print on my web application(asp.net). I want to show the page in WORD. I use that code in asp.net Page_Load event: Response.Clear(); Response.ContentType = "application/ms-word"; Response.AddHeader("Content-Disposition", "attachment;filename=word.doc");
When I open the page in IE shows a dialog to ask whether I want to open or save. It is ok. But when I click Open or Save button, I get an error message: " Internet Explorer cannot download form.aspx. Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later. "
What can I do to solve this problem?
hmm, it looks as if you are doing the right thing.
I presume you are streaming the binary contents of a word document directly after setting these headers. Have you checked the document itself is being sent correctly.
you could also try putting in a content-length header but I wouldn't have thought this was necessary.
Thanks in advance.
-- ______________________________ Senol Akbulak
hmm,
Well, word can certainly open an HTML file, but I wouldn't be at all
surprised if streaming HTML content to the browser with a content-type of
word didn't work.
Bear in mind that with content type you are supposed to be telling the
browser what type of file you are sending, and the browser is in charge of
deciding which application to use. There is no way in HTTP of saying "here's
some HTML, open it with word".
Andy
"Senol Akbulak" <se**********@newsgroup.nospam> wrote in message
news:8A**********************************@microsof t.com... My form content is for html. Is the problem that? Cannot Word open html content?
"Andy Fish" wrote:
"Senol Akbulak" <se**********@newsgroup.nospam> wrote in message news:26**********************************@microsof t.com... > Hi, > > I have a form page to print on my web application(asp.net). I want to > show > the page in WORD. I use that code in asp.net Page_Load event: > Response.Clear(); > Response.ContentType = "application/ms-word"; > Response.AddHeader("Content-Disposition", > "attachment;filename=word.doc"); > > When I open the page in IE shows a dialog to ask whether I want to open > or > save. It is ok. But when I click Open or Save button, I get an error > message: > " > Internet Explorer cannot download form.aspx. > Internet Explorer was not able to open this Internet site. The > requested > site is either unavailable or cannot be found. Please try again later. > " > > What can I do to solve this problem? >
hmm, it looks as if you are doing the right thing.
I presume you are streaming the binary contents of a word document directly after setting these headers. Have you checked the document itself is being sent correctly.
you could also try putting in a content-length header but I wouldn't have thought this was necessary.
> Thanks in advance. > > -- > ______________________________ > Senol Akbulak
Hi Senol,
I think Andy's suggestions are reasonable. Though WORD can open HTML
document correcdtly. The IE browser will check the mime-type of the
response stream first. If we output an HTML document but set the content
Type as word, that'll cause the problem. So I suggest you consider the
following options:
1. Convert the content to word compatible document (word or normal rtf)
2. Use text/html as the response's content Type. We can use
Response.AddHeader("Content-Disposition", "attachment;filename=xxxx");
to let the document be opened outside, but whether it'll be opened through
Word.exe will depened on the clientside's settings.
Please feel free to post here if you have any further questions. Thanks,
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Hi Steven,
I sorry, I just realized your answer.
I tried your second suggest, but I still get the same error message.
"Steven Cheng[MSFT]" wrote: Hi Senol,
I think Andy's suggestions are reasonable. Though WORD can open HTML document correcdtly. The IE browser will check the mime-type of the response stream first. If we output an HTML document but set the content Type as word, that'll cause the problem. So I suggest you consider the following options: 1. Convert the content to word compatible document (word or normal rtf)
2. Use text/html as the response's content Type. We can use
Response.AddHeader("Content-Disposition", "attachment;filename=xxxx");
to let the document be opened outside, but whether it'll be opened through Word.exe will depened on the clientside's settings.
Please feel free to post here if you have any further questions. Thanks,
Regards,
Steven Cheng Microsoft Online Support
Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.)
Thanks for your followup Senol,
Well, I'm not sure whether there is something incorrect on your server's
asp.net/iis environment. But is it ok for you to simple use
Response.WriteFile to output an existing word or excel document. For
example:
private void btnZIP_Click(object sender, System.EventArgs e)
{
Response.Clear();
Response.ContentType="application/msword";
Response.AddHeader("content-disposition","attachment; filename=mydoc.doc");
Response.WriteFile(Server.MapPath("~/files/mydoc.doc"));
Response.End();
}
If even this not work, I'm fraid there must be some environment specific
problems we need to troubleshooting.
Thanks,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Thank you at all!!!
I found the problem. The problem was that:
########################################
Response.Cache.SetCacheability(HttpCacheability.No Cache);
########################################
After deleting this line, it run successfully.
Thanks.
"Steven Cheng[MSFT]" wrote: Thanks for your followup Senol,
Well, I'm not sure whether there is something incorrect on your server's asp.net/iis environment. But is it ok for you to simple use Response.WriteFile to output an existing word or excel document. For example:
private void btnZIP_Click(object sender, System.EventArgs e) { Response.Clear(); Response.ContentType="application/msword"; Response.AddHeader("content-disposition","attachment; filename=mydoc.doc"); Response.WriteFile(Server.MapPath("~/files/mydoc.doc")); Response.End(); }
If even this not work, I'm fraid there must be some environment specific problems we need to troubleshooting.
Thanks,
Steven Cheng Microsoft Online Support
Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.)
Thanks for your followup.
I'm glad that everything works well now.
Have a good day!
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Hi There!
I followed the same method to open a web form report page in MS word.
How do I automate the Open [to avoid the file download dialog - would
you like to open the file or save it to your disk?]
Your help is greatly appreciated!
John
*** Sent via Developersdex http://www.developersdex.com ***
This is a client browser setting. It'd be a security vulnerability if you
could force an app to open on my machine.
-Brock
DevelopMentor http://staff.develop.com/ballen Hi There!
I followed the same method to open a web form report page in MS word. How do I automate the Open [to avoid the file download dialog - would you like to open the file or save it to your disk?]
Your help is greatly appreciated!
John
*** Sent via Developersdex http://www.developersdex.com *** This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Martin Lucas-Smith |
last post by:
I am trying to use PHP's COM support to open a URL from within MS Word
then save the document.
I am using PHP5.0.3/Apache2/WindowsXP. phpinfo() confirms that COM support
is enabled.
...
|
by: monika |
last post by:
Hi all...
I am able to select a student's story and open it in a word doc. the
teacher then corrects the story, highlight in colors the comments,
strikethrough. In fact all the privileges I...
|
by: TLMM |
last post by:
I have a Word doc already created that I want to open from an asp page. I
want it to open in Word and allow the user to modify if necessary. I
currently have it opening (using href), but it is...
|
by: Andrew |
last post by:
I'm adding this as it to me a while to figure out all the pieces to be
able to do this without using Microsoft.Office.Interop which caused me
problems on the web-server.
Streaming is the easy...
|
by: bhoff |
last post by:
I have a program where a user can click on a LinkLabel to open a word
document to view a reference. I can't figure out how to make word jump
to a specified page though, example:
A reference to...
|
by: =?Utf-8?B?UmF2aQ==?= |
last post by:
public WordApp()
{
//oWordAppl = new
Microsoft.Office.Interop.Word.ApplicationClass();
}
When I click a button in my aspx file I geet the followign error. I am
trying to open word from...
|
by: Peter |
last post by:
ASP.NET 2.0
I am trying to open a Word document and Excel document from a dialog web
page, what's the best way to do that?
I have tried the following:
Response.Clear();...
|
by: Peter |
last post by:
I have the following code which is executed from a modal web page - it works
fine on most, but on some computers the Word loads into memory but never
displays. This occurs with IE6 and IE7, but...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
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...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
|
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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |