添加 xml 到 http 重定向

发布于 2024-12-11 22:38:35 字数 674 浏览 0 评论 0原文

我遇到一种情况,我需要将用户从我的服务器上的页面重定向到另一台服务器上的页面。在此重定向中,我还需要向我重定向到的服务器发送一些 xml。该 xml 文件可能会很长,因此不能只在查询字符串中发送它。

我尝试将 xml 附加到标头中,但标头似乎无法将其发送到另一端。

我知道如何以编程方式创建发送 xml 的请求以及如何重定向,只是不确定如何同时执行这两项操作。

简而言之,我需要 xml 来承载重定向。此重定向将从 MVC 操作中完成。

提前致谢。

编辑

我针对我的问题提出了以下可能的解决方案。不幸的是,它确实利用了我希望避免的两个请求。

基本上,我将 xml 文件作为 post 请求的标头发送,其中还包含会话 id。这是异步发送的。

然后,我重定向用户,在查询字符串中传递相同的 sessionid。这充当将一个请求链接到另一个请求的令牌。我现在只需要等待,看看对方是否愿意使用两个请求来工作。

我还考虑使用一个额外的页面,我可以将用户重定向到该页面,该页面可以包含 Javascript,以便通过一个仅包含一个包含 xml 片段的字段的表单向其他服务器执行额外的表单发布,但这被排除在外我老板的一个可能性(正确,因为这看起来有点像黑客)。

除了两个请求之间存在竞争条件的明显可能性之外,我提出的方法是否还有任何明显或不明显的缺点?

I have a situation whereby I need to redirect a user from a page on my server to a page on another server. In this redirect I need to also send some xml to the server I am redirecting to. This xml file could be quite long so just sending it in the querystring isn't an option.

I have tried attaching the xml in a header but the header doesn't seem to make it to the other end.

I know how to programmatically create requests to send xml and how to redirect, just not sure how to do both at the same time.

In short, I need the xml to piggy-back on the redirect. This redirect will be done from within an MVC Action.

Thanks in advance.

Edit

I have come up with the following potential solution to my problem. Unfortunately it does utilise two requests which I had hoped to avoid.

Basically I send the xml file as a header of a post request which also contains a session id. This is sent asynchronously.

I then redirect the user, passing the same sessionid in the querystring. This acts as a token to link one request to the other. I just need to wait now and find out if the other party are willing to work using two requests.

I also looked in to using an additional page that I could redirect the user to which could contain Javascript to perform an additional form post to the other server with a form that would contain just a single field containing the xml fragment, but this was excluded as a possibility by my boss (rightly so as it seems like a bit of a hack).

Are there any obvious or non-obvious drawbacks to my proposed method, other than the obvious possibility of a race condition between the 2 requests?

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

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