I have a response.redirect in an asp page that works fine in chrome, opera, firefox etc but doesnt work in IE8. The code is simple enough, as below:

dim news_item
news_item = Request.QueryString()
Response.Redirect "newsitem.asp?id=" & news_item

The page is news.asp, that was writen by previous developer that has one parameter for the news item id (e.g. news?3456, and wont work if you add another parameter and use request.querystring()which now needs another parameter to allow for extra code, so I could then use request.querystring("id")). This is why the new page has an id= instead of just ?.
In IE8 I get the error message: "Internet Explorer cannot display the webpage" I can't see where the problem is and can't find any similar forum with this problem, can anybody shed any light on this? Thanks

Dani AI

Generated

Quick summary and likely cause — the IE8 error usually means the browser couldn't follow the server's Location header rather than a JavaScript/display bug. 's parentheses and 's note about named parameters are fine syntax-wise, but the root problem is often the redirect target: a malformed or un-encoded query value, stray CR/LF characters (header injection), or an unusual query format (for example the old news?3456 style instead of ?id=3456).

Try these focused steps to find and fix it.

  1. Inspect what the server is actually sending
    Temporarily stop redirecting and print the exact target URL so you can see any hidden characters:
dim rawQS, target
rawQS = Request.ServerVariables("QUERY_STRING")
target = "/newsitem.asp?id=" & rawQS
Response.Write "<pre>Would redirect to: " & Server.HTMLEncode(target) & "</pre>"
Response.End

Also capture the real HTTP/302 response with a tool such as Fiddler to confirm the Location header the server emitted.

  1. Sanitize and send a safe, absolute Location
    Remove CR/LF, validate the value, URL-encode it, and send an absolute Location header instead of relying on a relative redirect:
Function CleanForHeader(s)
  s = Replace(s, vbCr, "")
  s = Replace(s, vbLf, "")
  CleanForHeader = Server.URLEncode(s)
End Function

dim raw, safe, loc
raw = Request.ServerVariables("QUERY_STRING")
If Not IsNumeric(raw) Then
  Response.Status = "400 Bad Request"
  Response.End
End If

safe = CleanForHeader(raw)
loc = "http://" & Request.ServerVariables("HTTP_HOST") & "/newsitem.asp?id=" & safe

Response.Clear
Response.AddHeader "Location", loc
Response.Status = "302 Found"
Response.End
  1. Final checks and security
  • Validate expected formats (IsNumeric or a regex) to avoid open-redirects.
  • If the site originally uses news?3456, parse the raw query string (Request.ServerVariables("QUERY_STRING")) rather than assuming a named key.
  • If the problem only appears in IE8, Fiddler will show whether the Location header is malformed; fix the header and IE8 will behave.

These steps isolate whether the value being placed in the redirect is the culprit and also show how to build a safe, standards-compliant redirect that works across browsers.

Should work as is but try...

Response.Redirect("newsitem.asp?id=" & news_item)
dim news_item
news_item = Request.QueryString("id")
Response.Redirect "newsitem.asp?id=" & news_item
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.