Error when Request.QueryString is empty

徘徊边缘 提交于 2019-12-19 04:02:11

问题


Sometimes users mistakenly redirected to ?Process=ViewImages&PAGEID=. When this happens, they get the following error.

Microsoft VBScript runtime error '800a000d'

Type mismatch: '[string: ""]'

/FLPM/cp/images.cs.asp, line 91

I tried to fix it with the following codes but still get the same error.

PAGEID = Request.QueryString("PAGEID")

If PAGEID = "" or PAGEID = NULL or PAGEID = 0 Then
    PAGEID = 1
End If

回答1:


if IsNumeric(pageId) and pageId <> "" then
  pageId = Cint(pageId)
else
  pageId = 1
end if

this will check if the pageId has a value and is a numeric value, before accepting it..




回答2:


Classic ASP uses VBScript. So your PAGEID is dynamically cast, and since it is empty you cannot compare it to a string. You will also get an error if you try and compare the length, substr and so on.

if ISNull(PAGEID) then PAGEID = 1



回答3:


You are in VBScript I believe you need to swap this around a bit, and first check

IF ISEmpty(PAGEID) THEN PAGEID = 1 End IF

You want to validate that it is empty, not null. Here is an article that explains a bit about the way Empty, Null, and Nothing work.



来源:https://stackoverflow.com/questions/2425929/error-when-request-querystring-is-empty

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!