简体   繁体   English

经典的ASP-response.redirect和response.write问题

[英]classic asp - response.redirect and response.write problem

The problem if someone types into the search box a location it goes through to that location page but if they type in a location thats not found or they dont type anything in I need it to redirect back to the homepage (index.asp) and display "whoops we couldnt find that" in the search box (input field) 问题是,如果有人在搜索框中键入要转到该位置页面的位置,但是如果他们键入找不到的位置,或者他们没有输入任何内容,则需要将其重定向回首页(index.asp)并显示搜索框(输入字段)中“ whops we not found that”

This is the vb 这是vb

    Case Else
    response.redirect "index.asp?whoops=whoops we couldnt find that"
End Select

Then in the value of the input field I have 然后在输入字段的值中

value="<% =whoops %>"

This doesnt work by the way, first is this the best way of doing it because id rather not have the error message in the url. 顺便说一句,这是行不通的,首先是这样做的最佳方法,因为id而不是URL中没有错误消息。 This there away of posting the error as a variable and then calling it into the input field like, 这样就可以将错误作为变量发布,然后将其调用到输入字段中,例如,

<% =whoops %>

You don't need the error message in the url. 您不需要网址中的错误消息。 Also, whoops won't be available to you as a variable just because it is in the url. 另外, whoops不能仅作为变量存在于URL中而作为变量使用。 You have to look for it in the Request.Querystring collection. 您必须在Request.Querystring集合中查找它。 What you'd want to do is something more like this on the homepage: 您要做的是在首页上执行以下操作:

Dim whoops : whoops = ""
If Request.Querystring("whoops") Then
    whoops = "whoops we couldnt find that"
End If

Then you could output <%=whoops %> as the search box's HTML value attribute. 然后,您可以输出<%= whoops%>作为搜索框的HTML值属性。 This would also prevent people from being able to assign whatever they want to the value of whoops, which is a security vulnerability. 这也将阻止人们将他们想要的任何东西分配给whoops的值,这是一个安全漏洞。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM