I see a lot of ASP.NET programmers still using the Request.ServerVariables collection to get specific information they need like url paths, is https active, or the full query string. It’s time to move on and start using the Request object as it should be used.

Below are some examples of the old way using ServerVariables and the new way:

You can also get any part of the url you want. Some examples:

… and much more!

Headers in raw form

Headers is a collection so you can do this:

QueryString is a collection so for a query string “?test=false&hello=you” you can do this:

These are just a few examples on the information you can get your hands on without using Server Variables.