我创建了 CRM 插件,在创建案例时需要将文档下载到客户端。当我创建案例时,插件正在工作,但它不下载文档。
在控制台中我可以看到通过 POST 请求返回文档内容
..AppWebServices/InlineEditWebService.asmx 但未打开或下载。
我是新手,所以我将非常感谢任何帮助。我的代码如下:
我的代码如下:
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();
}
不支持在插件中调整 HttpResponse,应尽一切努力避免。换句话说,您无法使用插件来执行此操作。
当您需要在 Dynamics CRM for (Word) 文档中提供下载选项时,解决方案可能是创建一个包含下载页面的单独网站。然后,您可以通过 IFrame 或 HTML Web 资源将此页面集成到 CRM 中。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)