我有一个弹性网络应用程序,当用户按下按钮时,它会向服务器发出服务调用。在服务调用中,会创建一个自定义导出器对象,并在该对象中使用 iTextSharp 生成一个 PDF 文件。我希望能够在该服务调用中生成文件位置的 url,并将其传递回 flex 应用程序以与 FileReference.download() 一起使用。服务调用只是从传递给函数的 id 中获取保存 PDF 所需数据的对象,创建导出器对象并发回文件路径。在导出器对象的导出函数中,它看起来像这样:
this.ObjectId = object.Id;
Document doc = new Document();
PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream("C:/temp/TestBoth.pdf", FileMode.Create));
MyPageEventHandler e = new MyPageEventHandler(this.ObjectId);
writer.PageEvent = e;
doc.Open();
this.ExportThingOne(object, true, doc, writer);
doc.NewPage();
this.ExportThingTwo(object, true, doc);
doc.Close();
System.Web.UI.Page page = new System.Web.UI.Page();
string serverPath = page.Server.MapPath("C:/temp/TestBoth.pdf");
return serverPath;
该文件在我的本地计算机上的 C:/temp/TestBoth.pdf 完美生成(仅在推送到实际服务器之前在本地测试内容),但是当我尝试page.Server.MapPath("C:/temp/TestBoth.pdf");
. 我是否错过了将页面服务器设置为某些内容的步骤,或者是否有其他方法可以获取服务器路径?