简体   繁体   English

WCF Azure使用DevExpress在虚拟目录中创建PDF文件

[英]WCF Azure create PDF file in virtual directory with DevExpress

We have a wcf service that uses DevExpress XtraReports to generate a pdf file. 我们有一个wcf服务,该服务使用DevExpress XtraReports生成pdf文件。

How this normally works is we have in the web.config the physical directory Example C:\\PdfDocs\\ that we specify as the path when executing the devexpress ExportToPdf function. 这通常是如何工作的,我们在web.config中具有物理目录示例C:\\ PdfDocs \\,在执行devexpress ExportToPdf函数时将其指定为路径。 This works fine on a normal virtual machine. 在正常的虚拟机上可以正常工作。

We are now busy moving to Microsoft Azure enviroment and I am having trouble getting this to work. 现在,我们正忙于迁移到Microsoft Azure环境,但我无法使其正常工作。

My Setup - The wcf service is created as a App Service. 我的设置-wcf服务创建为应用程序服务。 Unfortunately I am not at liberty to give names so lets assume the following: 不幸的是,我不能随意命名,因此请假设以下内容:

App Service Name - testdocservice, Url Azure gives - https://testdocservices.azurewebsites.net 应用服务名称- testdocservice,URL天青给- https://testdocservices.azurewebsites.net

What I have tried: 我尝试过的

In Application settings, I have created a virtual directory. 在“应用程序设置”中,我已经创建了一个虚拟目录。 In the project itself I have created a folder that the virtual directory will point to. 在项目本身中,我创建了虚拟目录将指向的文件夹。

The virtual path is https://testdocservices.azurewebsites.net/ItinDocs and the physical path is site\\wwwroot\\ItinDocuments 虚拟路径为https://testdocservices.azurewebsites.net/ItinDocs ,物理路径为site \\ wwwroot \\ ItinDocuments

This is setup correctly as I have tested it by FTP test pdf in and then hit the following url: https://testdocservices.azurewebsites.net/ItinDocs/test.pdf 这是正确设置的,因为我已经通过FTP测试pdf对它进行了测试,然后单击以下URL: https : //testdocservices.azurewebsites.net/ItinDocs/test.pdf

So in the wcf service I took a chance and set the location to render the pdf to "site\\wwwroot\\ItinDocuments" - This did not work. 因此,在wcf服务中,我抓住了一个机会,并设置了将pdf呈现为“ site \\ wwwroot \\ ItinDocuments”的位置-这不起作用。

The exception was as follows: Access to the path 'D:\\Windows\\system32\\site\\wwwroot\\ItinDocuments\\TestQuote21.pdf' is denied. 例外情况如下:拒绝访问路径“ D:\\ Windows \\ system32 \\ site \\ wwwroot \\ ItinDocuments \\ TestQuote21.pdf”。

I then tried using Server.MapPath example: 然后,我尝试使用Server.MapPath示例:

QuoteV3 oQuote = new QuoteV3();
            oQuote.DataSource = dSource;
            oQuote.ExportToPdf(System.Web.HttpContext.Current.Server.MapPath($"~{ConfigurationManager.AppSettings["DocLocation"]}{fileName}"));

The DocLocation look like the following: site\\wwwroot\\ItinDocuments\\ DocLocation如下所示:site \\ wwwroot \\ ItinDocuments \\

This also did not work. 这也没有用。 The following error is given: 给出以下错误:

'~https:/testdocservices.azurewebsites.net/ItinDocs/TestQuote21.pdf' is not a valid virtual path. “〜https:/testdocservices.azurewebsites.net/ItinDocs/TestQuote21.pdf”不是有效的虚拟路径。

I thought the first character "~" could be a problem so I removed it and got the same error as above - 'https:/testdocservices.azurewebsites.net/ItinDocs/TravelQuote21.pdf' is not a valid virtual path. 我以为第一个字符“〜”可能是一个问题,因此我将其删除并得到与上述相同的错误-“ https:/testdocservices.azurewebsites.net/ItinDocs/TravelQuote21.pdf”不是有效的虚拟路径。

I then noticed that the above errors only have one forward-slash after the https. 然后,我注意到上述错误在https之后仅带有一个正斜杠。 At this point I am not sure if that could be causing the problem and then how to correct it as the Server.MapPath is generating that part. 在这一点上,我不确定这是否可能导致问题,然后在Server.MapPath生成该部分时如何解决。

In conclusion, I am not sure if I am even working in the right direction with the above approach. 总之,我不确定是否可以通过上述方法在正确的方向上工作。 My knowledge around azure is still minimal. 我对天蓝色的了解仍然很少。

Any help/assistance/solution would be greatly appreciated. 任何帮助/协助/解决方案将不胜感激。

Many thanks. 非常感谢。

This can be closed as I have instead setup azure storage and my pdfs are saving in a container instead. 可以关闭此窗口,因为我改为设置了azure存储,而我的pdf却保存在了容器中。

Thanks. 谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM