ASP/VB 字节数组、iframe、父项、子项和变量

发布于 2024-11-16 16:00:59 字数 727 浏览 3 评论 0原文

我有一个包含 iframe 的 aspx 页面。单击按钮时,将调用 WCF 来生成 PDF,并将其读入字节数组。我将字节数组存储在 Globals.vb 文件中,如下所示:

Public Shared PDF_Data as Byte()

全局是从父 aspx 页面加载的,如下所示:

PDF_Data = MyWCF.Create_PDF_File(SomeVariable)

之后,iFrame 的 src 被设置为空白 aspx 页面,其中包含page_load 事件中的以下代码:

    'Write the PDF binary data to the screen (viewer)
    Response.Clear()
    Response.Buffer = True
    Response.ContentType = "application/pdf"
    Response.BinaryWrite(Globals.PDF_Data.ToArray)

但是,意识到该应用程序将有多个用户将获得不同的 PDF 文档,我了解到这不是正确的方法。我的共享变量可供所有用户访问,这是一个很大的禁忌。

然而,我对如何存储字节数组并使其可从其父级的子 aspx 页面使用感到困惑。

任何想法将不胜感激!

谢谢,

杰森

I have an aspx page which houses an iframe. When a button is clicked, a WCF is called to produce a PDF which is read into a byte array. I was storing the byte array in a Globals.vb file like this:

Public Shared PDF_Data as Byte()

The global was loaded from the parent aspx page like this:

PDF_Data = MyWCF.Create_PDF_File(SomeVariable)

After that, the iFrame's src was set to a blank aspx page, which had the following code in the page_load event:

    'Write the PDF binary data to the screen (viewer)
    Response.Clear()
    Response.Buffer = True
    Response.ContentType = "application/pdf"
    Response.BinaryWrite(Globals.PDF_Data.ToArray)

However, realizing that this application will have several users who will get different PDF documents, I have learned that this is not the way to go. My shared variable would be accessible to all users, a big no-no.

However, I am stumped as to how I'm going to store the byte array and make it available to a child aspx page from it's parent.

Any ideas would be greatly appreciated!

Thanks,

Jason

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

岁月打碎记忆 2024-11-23 16:00:59

共享变量绝对不是正确的选择。我接手了一个使用该技术的项目,并且一个用户获取另一个用户数据时存在很多问题。您应该使用 Session,这本身就是一个问题。

一项建议是,我使用一个键将字节数据保存到数据库中,并使用查询字符串将该键传递到 URL 内的 iframe。在这种情况下,您应该有办法在数据库占用太多空间之前清除过去的记录。根据该 PDF 文档是否安全,该文档将会打开,以便摆弄查询字符串的人可以访问该 PDF。

另一个建议,将其作为 B64 编码的 POST 数据传递。这是一些建议。

The shared variable is definitely not the way to go. I took over a project that used that technique and there were slews of issues with one user getting another users data. You should either use Session, which in itself can be an issue.

One suggestion that I've used saving the byte data to a database with a key and passing that key to the iframe within the URL with the query string. In that case, you should have a way to clear out the past records from the db before it takes up too much space. Depending on if this PDF document is supposed to be secure, this will open up so that the PDF would be accessible by people fiddling with the query string.

Another suggestion, passing it as B64 encoded POST data. Those are a couple suggestions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文