Click here to Skip to main content
15,845,565 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am writing a web application to look up information about year, make, and model of cars. I want to detect if the URL passed to the server is DX 2 and 4 Dr.

(I am not putting the '%20' in the above because we can understand that the URL will be properly encoded/decoded and we don't need to belabor that)

So, in the Global.asax.cs file, I get the value of Request.Url.PathAndQuery to determine whether a URL like this is passed. Only thing is, when I pass this URL to the server and I Thing is, not all car models end with a period, so I cannot know a priori which ones have periods and which do not.

Is this normal for Request.Url.PathAndQuery to drop the ending '.' on the end of a URL? If so, is there another property of Request that I can access in order to get the whole URL, period and all?

1 solution

I'm guessing that the PathAndQuery is assuming that the "Civic DX 2 and 4 Dr." part is a filename. In this case it is dropping the period because it wouldn't be considered part of the filename, but rather the extension.
Share this answer
Brian C Hart 27-Oct-11 13:27pm    
I sort of kind of suspected that, but I guess what I am still asking is, then, is there another property of "Request" that I can use to get the raw, un altered URL that the user has typed in the browser bar, without any alterations?
fjdiewornncalwe 27-Oct-11 13:41pm    
Not sure if this will work for sure, but I have used it in the past. Try the Request.Url.Segments object. It is a simple string array comprising the array elements. Look at the last item in the array and see if it gives you the period maybe.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900