经典 ASP 重定向标题问题

发布于 2025-01-03 19:13:28 字数 294 浏览 1 评论 0原文

只是想知道 ASP 执行两个级别的 Server.Transfer 有什么限制?因此,一个页面转移到另一个页面,然后再转移到另一个页面。

这是我们当前的设置。为了取悦搜索引擎优化,我们创建了包含关键字的“假”网址。然后,我们有一个 404 错误处理程序 (IIS) 接收这些信息,重定向到另一个 ASP 页面,该页面从 URL 中提取一些关键信息,并执行 Server.Transfer 到我们的“真实”页面。由于超出本文范围的原因,我需要从此页面进行进一步的 Server.Transfer。我们现在所在的页面需要设置页面标题。

这可能吗?

Just wondering what limitations there are in ASP doing a Server.Transfer two levels? So a page transferring to another page that then transfers to one more page.

Here is our current setup. In an attempt to please SEO, we have created "fake" URLs containing keywords. We then have a 404 error handler (IIS) picking these up, redirecting to another ASP page which pulls out some key information from the URL, and does a Server.Transfer to our "real" page. For reasons outside the scope of this post, it is required that I make a further Server.Transfer from this page. The page we are now on needs to set the page title.

Is this possible?

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

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

发布评论

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

评论(1

反话 2025-01-10 19:13:28

你想要的当然是可能的。

当然,有一些限制...但是,限制不是您计划菊花链的服务器传输数量...只要确保您最终不会造成恶性循环:)

限制如下;
server.transfer(和 server.execute 也一样)无法访问前一页的变量上下文。

因此,如果您在 page1 中设置一个变量 Age=50,并且 page1 执行 server.transfer 到 page2,则不要期望 page2 知道有关声明的 Age 变量的任何信息 &由第1页设置。事实上,您甚至可以在 page2 中调暗相同的变量(年龄),您不会收到错误。这是因为,.transfer'ed 页面和 .execute'd 页面都不像 [!--include...] 文件那样工作......

那么该怎么办?如何在计划使用 server.transfer 进行菊花链的页面之间共享信息?答案是使用会话变量!这是一种有效的方法..(当然,您可能会不遗余力地写入数据库或文本文件,但为什么?)

您的 page2 和 page3 可以从原始 page1 共享的唯一另一件事是查询字符串,并发布& cookie 数据!这些请求集合在传输(或执行)的页面中仍然可用。这意味着如果原始页面(page1)被点击为 page1.asp?age=,则您可以在 page2 和 page3 中执行 request("age") 无论如何, 99

,回到你的组织。问题...你想要的当然是可行的...
只是不要在 page1 中设置任何变量,只需使用会话变量...

并且在完成最后一页时不要忘记清理会话变量。

希望这对你有帮助...

What you want is certainly possible.

Sure, there are some limitations... but, the limitations are not on the number of server transfers which you plan to daisy chain... Just make sure you don't end up creating a vicious cycle :)

the limitation is as follows;
server.transfer ( and server.execute too for that matter ) cannot access the previous page's variable context.

so if you set a variable say Age=50 in page1 and page1 does a server.transfer to page2, do not expect page2 to know anything about that Age variable declared & set by the page1. In fact, you can even Dim the same variable (Age) in page2, you won't get an error. This is because, neither the .transfer'ed, nor the .execute'd pages work like the [!--include...] files...

So what to do? How do you share information among those pages that you plan to daisy chain using server.transfer? The answer is to use session variables!. That's one effective way.. ( of course you may go out of your way to write to db or text files, but why? )

The only the other thing that your page2, and page3 could share from the the original page1 is the querystring, and post & cookie data! Those request collections will still be available in the transferred ( or executed ) pages.. This means that you can do request("age") in both page2 and page3 if the original page ( page1) was hit as page1.asp?age=99

anyway, coming back to your org. question... what you want is certainly doable...
just don't set any variables in page1, simply work with session variables...

and don't forget to clean up the session vars when you are done on the final page.

hope this helps you...

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