2014-02-19 24 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,您将打破事件的管道并导致事务不完整。

相关问题