【问题标题】:Classic ASP Redirect URL using variable使用变量的经典 ASP 重定向 URL
【发布时间】:2012-10-15 02:25:28
【问题描述】:

我有一个来自结果集的变量标签 。

我想用这个 重定向到一个链接,比如说

http://www.helloworld.someurl.com/testUrl?somevariable=<%=test_variable%>&test=ok

如何在 标记中执行此操作?例如,

<%=test_variable%> 

<%
' I want to redirect the url with the above tag, something like:

Response.Redirect(" http://www.helloworld.someurl.com/testUrl?somevariable=<%=test_variable%>&test=ok")
%>

但我不认为我们可以有“嵌套标签”,对吧?

我对 ASP 还是很陌生。

【问题讨论】:

  • 明确您的问题。您想重定向到某个页面。如果有什么你想发送到那个 url?

标签: url asp-classic response.redirect


【解决方案1】:

&lt;%= %&gt; 是&lt;% Response.Write(" ... "); %&gt; 的简写:

http://www.helloworld.someurl.com/testUrl?somevariable=<%=test_variable%>&test=ok

在您澄清之后:

<%
    Response.Redirect("http://www.helloworld.someurl.com/testUrl?somevariable="
                     + test_variable
                     + "&test=ok");
%>

【讨论】:

  • 呃,我不认为你理解我的问题......我想这样做:变量: ;) %> 但是我们不能有 2 个连续的标签?- prog 饭碗 1 分钟前编辑
  • 请注意,如果您使用 VBScript 作为服务器端语言(在经典 ASP 中更常见),那么您应该使用 &amp; 而不是 + 将字符串连接在一起.
【解决方案2】:

你的代码应该是

Response.Redirect("http://www.helloworld.someurl.com/testUrl?somevariable=" & test_variable & "&test=ok")

【讨论】:

    【解决方案3】:

    感谢大家的建议...

    我决定改用这个:

    <script type="text/javascript">
       window.location =  "http://www.helloworld.someurl.com/testUrl?somevariable="+<%=test_variable%>+"&test=ok"
    </script>
    

    【讨论】:

    • 这将起作用,但请注意,您现在将进行客户端重定向,而不是服务器端重定向。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-25
    相关资源
    最近更新 更多