Dynamic CRM Plugin download Word document

耗尽温柔 提交于 2019-12-02 04:22:30

问题


I have created CRM plugin, which on Case create need to download a document to the client. When I create a case plugin is working but it doesnt download a document. In console i can see a content of document is returned through POST request ..AppWebServices/InlineEditWebService.asmx but not opened or downloaded.

Im new in this so I will be a very thankful on any help. My code is bellow:

My code is bellow:

protected void ExecutePreValidateCaseCreate(LocalPluginContext localContext)
{
if (localContext == null)
{
   throw new ArgumentNullException("localContext");
}
String FileName = "Test.docx";
String FilePath = @"C:\Template\temp\Test.docx"; 

HttpContext.Current.Response.Clear();
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + FileName);
HttpContext.Current.Response.ContentType = "application/force-download";
HttpContext.Current.Response.TransmitFile(FilePath);
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.End();
} 

回答1:


Tweaking the HttpResponse in a plugin is not supported and should be avoided by all means. In other words, you cannot do this using a plugin.

When you need to offer a download option in Dynamics CRM for (Word) documents, a solution could be to create a separate web site containing a download page. Then you can integrate this page into CRM by means of an IFrame or HTML web resource.



来源:https://stackoverflow.com/questions/30889029/dynamic-crm-plugin-download-word-document

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!