ASP Classic, check if Querystring is UCase or LCase

Hello All;

I designed a lot of my sites with a certain case sensitive structure.
Of which in the most part, has never been an issue.
But there is always the time when someone might type out the URL to a location on the site.
And they do lowercase instead of Uppercase.

What I would like to be able to accomplish, is to check if the string is all lowercase and if it is.
Check the URL and do a redirect.
Well, without doing an endless LOOP. (That is what I am afraid of)

So, how would you check?
main.asp?type=something
And then have it changed to
main.asp?Type=Something

Any ideas on this one?
(And yes, I know. I have read where it is bad programming to do it like I have, but this was done such a long time ago.
And there is well over 100+ pages per site, that I would have to change. Not quite ready to do that yet.)
Thanks, all.
Carrzkiss
LVL 31
Wayne BarronAuthor, Web DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
for asp websites, it really doesn't matter if you give the parameters as uppercase or lowercase.

this is a simple test:

<%

    response.write("request(""type"") = " & request("type") & "<br>")
    response.write("request(""Type"") = " & request("Type") & "<br>")
    response.write("request(""TYpE"") = " & request("TYpE") & "<br>")
    response.write("request(""tyPE"") = " & request("tyPE") & "<br>")

%>

Open in new window


but certainly, for values, it do make difference.
0
Wayne BarronAuthor, Web DeveloperAuthor Commented:
It is the values.
I should have made that clear. Sorry.
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
you probably can test using some codes like this:

<%

response.write("Test 1 = " & getOutput("dfij23ed") & "<br>")
response.write("Test 2 = " & getOutput("H %j23ed") & "<br>")
response.write("Test 3 = " & getOutput("df%d") & "<br>")
response.write("Test 4 = " & getOutput("323x") & "<br>")
response.write("Test 5 = " & getOutput("dfijz23ed") & "<br>")
response.write("Test 6 = " & getOutput("633") & "<br>")
response.write("Test 7 = " & getOutput("!@#$%Fd") & "<br>")
response.write("Test 8 = " & getOutput("HHYx") & "<br>")
response.write("Test 9 = " & getOutput("df632ed") & "<br>")
response.write("Test 10 = " & getOutput("ABC") & "<br>")

function getOutput(value)
    rtn = isAllLowerCase(value)
    if rtn then
        getOutput = value & " is " & rtn
    else
        getOutput = "<font color='red'>" & value & " is " & rtn & "</font>"
    end if
end function

function isAllLowerCase(value)
    for i = 1 to len(value)
        v = mid(value, i, 1)
        if asc(v) >= 65 and asc(v) <= 90 then
            isAllLowerCase = false
            exit function
        end if
    next
    isAllLowerCase = true
end function

%>

Open in new window


to apply to your verification, use isAllLowerCase(value) and replace the value with querystring.
0
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Wayne BarronAuthor, Web DeveloperAuthor Commented:
How would I use it to test against the Querystring?

Type=something
that supposed to be
Type=Something
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
try this?

<%

dim key
if Request.Querystring = "" then
    response.write "nothing in Request.Querystring" 
else
    for each key in Request.Querystring
        Response.Write "QueryString " &  getOutput(Request.Querystring(key)) & "<BR>"
    next
end if

function getOutput(value)
    rtn = isAllLowerCase(value)
    if rtn then
        getOutput = value & " is " & rtn
    else
        getOutput = "<font color='red'>" & value & " is " & rtn & "</font>"
    end if
end function

function isAllLowerCase(value)
    for i = 1 to len(value)
        v = mid(value, i, 1)
        if asc(v) >= 65 and asc(v) <= 90 then
            isAllLowerCase = false
            exit function
        end if
    next
    isAllLowerCase = true
end function

%>

Open in new window


then pass it like:

yourTestpage.asp?Type=Something&bla=12346&U=ABC
yourTestpage.asp?Type=something&bla=12346S1&U=abc

Open in new window

1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Wayne BarronAuthor, Web DeveloperAuthor Commented:
Hey, Ryan.

I test it out, and it works like a charm.
I am assuming that I would add the Redirect to here.

[code]    isAllLowerCase = true
      response.Redirect "?Type=Something"
end function[/code]
As this is what I did, and the test works pretty good.
I type in the following URL: Type=something
And it reloads the page to: Type=Something

Love it.
Thank you, very much.
Now, I have to implement it into the test site.
It is going to be a week before this site is ready to be sent live to update the existing site.
So, I will have all that time to test it out to make sure that everything is going to work right.

You rock my friend.
Have a rockin rest of the week.
Wayne
1
Wayne BarronAuthor, Web DeveloperAuthor Commented:
I am doing this with it, and it is working great.

    isAllLowerCase = true
	if request.QueryString("Type")="artlist" then
	response.Redirect "?Type=ArtList"
	end if
end function

Open in new window

This way I can control what gets checked and redirected.

Please, let me know if this would cause an issue.
Wayne
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
let me know if this would cause an issue.

    isAllLowerCase = true
	if request.QueryString("Type")="artlist" then
	response.Redirect "?Type=ArtList"
	end if
end function

Open in new window


yup this should work well. but you may consider few issues:

1. reusability - can this code be reuse in some where else in your asp web pages?
2. configurability - how easy and frequent if we want to edit the values?
0
Wayne BarronAuthor, Web DeveloperAuthor Commented:
Hey, Ryan.
This code would wonderfully.
I have it setup to capture all pages and no issue.

I do have one slight thing, though.

Every page you see:
info is True
Thread is True
Forum is True, etc...

How can I either, HIDE or get rid of this?
Having it showing all the time is not a good thing.
Though on the regular site, it is hidden behind the HEADER.
But that is not the case for mobile. It is shown right under the Menu, on every page.

Any idea's on this would be wonderful.
Wayne
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
Every page you see:
info is True
Thread is True
Forum is True, etc...

what do you mean by that?

are that "info", "Thread", and "Forum" the variables?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.