Avatar of Wayne Barron
Wayne Barron
Flag for United States of America asked on

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
ASP

Avatar of undefined
Last Comment
Ryan Chong

8/22/2022 - Mon
Ryan Chong

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.
Wayne Barron

ASKER
It is the values.
I should have made that clear. Sorry.
Ryan Chong

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.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Wayne Barron

ASKER
How would I use it to test against the Querystring?

Type=something
that supposed to be
Type=Something
ASKER CERTIFIED SOLUTION
Ryan Chong

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Wayne Barron

ASKER
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
Wayne Barron

ASKER
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
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Ryan Chong

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?
Wayne Barron

ASKER
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
Ryan Chong

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?
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck