none
Open a word document from database (using http handler) without Open/ Save Dialog RRS feed

  • Question

  • Am trying to open a word document saved in database, using a handler.

    When I open the Word Doc, It throws the Open/Save Dialog. I would like to get rid of this dialog, and open directly in Ms Word Application.

    My code snippet is like this,

    URL: http://localhost/openword.ashx?wordId=123

    openwordhandler.cs code is something like this,

    ProcessRequest(HttpContect context)

    {

                  Byte[] wordbytes = GetWordFileFromDB(123);

                  context.Response.ClearHeaders();
                    context.Response.ClearContent();
                    context.Response.Buffer = false;
                    context.Response.AppendHeader("content-disposition","inline; filename="+123+".docx");
                    context.Response.ContentEncoding = System.Text.Encoding.UTF8;
                    context.Response.ContentType = "application/ms-word";
                    context.Response.BinaryWrite(wordbytes);
                    context.Response.Flush();
                    context.Response.Close();
         context.ApplicationInstance.CompleteRequest();                                                                                            

    Let me know your inputs.

    Thanks,

    RameshSubburaj



    Tuesday, October 29, 2013 12:54 PM

Answers

  • Hi RameshSubburaj,

    Thanks for posting on MSDN forum.

    According to your description, you want to get rid of the Open/ Save Dialog like figure below:

    As far as I know, the dialog is pop up by the Internet Explorer, I can hardly find an option we can set to get rid of the dialog. Since this issue is more relate ASP.Net Web Forms , I suggest you to repost to ASP.Net Web Forms forum to get more effective response.

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, October 31, 2013 3:40 AM
    Moderator