2014-02-19 25 views
-1

我使用下面的httpcontext來製作電子郵件實體的描述文字文件。它工作正常,但在執行doc文件後禁用表單。在crm 2011插件中使用httpcontext使用c#

private void exporToWord(string subject, string html) 
     { 

      string strFileName = subject + ".doc"; 

      HttpContext.Current.Response.AddHeader("Content-Disposition", "inline;filename=" + strFileName); 
      HttpContext.Current.Response.Clear(); 
      HttpContext.Current.Response.Charset = ""; 

      HttpContext.Current.Response.ContentType = "application/msword"; 
      StringBuilder strHTMLContent = new StringBuilder(); 
      strHTMLContent.Append(html); 
      HttpContext.Current.Response.Write(strHTMLContent); 
      //HttpContext.Current.Response.End(); 
      HttpContext.Current.ApplicationInstance.CompleteRequest(); 
      HttpContext.Current.Response.Flush(); 

     }//End of exporToWord() 

主題是電子郵件活動的主題,html是活動的描述。

請問我想在這方面尋求你的善意幫助。

謝謝。

+0

@Moderators重複的問題 - http://stackoverflow.com/questions/21880222/use-httpcontext-in-crm-2011-plugin-using-c-sharp –

+0

我正在關注此CRM 2011插件,但問題仍然存在相同的http://social.msdn.microsoft.com/Forums/sharepoint/en-US/590d4fe2-4c70-4971-99a4-45c22534215b/download-file-problem-in-user-control-loader-web-part – user2951753

+0

這並不意味着你需要每天用相同的問題創建新的線程。 –

回答

0

不支持從CRM插件寫入HttpContext的功能。

一個CRM插件在事件期間總是被觸發。如果它是同步插件,則該事件的結束將是對呼叫客戶端的響應。如果您在插件中寫出HttpContext,您將打破事件的管道並導致事務不完整。

相關問題