I think its a theoratical Question. I have a project on dotnet framework 4.5 and what i need to do is that whenever a client is using older httpversion i have to redirect it to an error page. i am getting http version like this
var d = Request.ServerVariables["SERVER_PROTOCOL"];
and it is giving value "HTTP/1.1". I think this is the http version of Request. Right? now my Question is
//
CASE 1) do we have to set http version on server and compare our server version with the version that we get from Request.ServerVariables["SERVER_PROTOCOLS"] OR
//
CASE 2) i have to compare it with latest http version(which is showing HTTP/2 on google) via a simple string comparison
var d = Request.ServerVariables["SERVER_PROTOCOL"];
if(d=="HTTP1.1") //"HTTP/2 either of which is latest"
{}
if its the CASE 1 then how do we set http version of our server and if it CASE 2 then what if later httpversion changes to "HTTP/3" then do i have to go to code again and change the condition for latest httpversion
I am getting http version like this
var d => Request.ServerVariables["SERVER_PROTOCOL"];
and it is giving value "HTTP/1.1". I think this is the http version of Request. Right?
Yes
Do we have to set http version on server and compare our server version with the version that we get from Request.ServerVariables["SERVER_PROTOCOLS"]
It is totally up to you what version you want to support. If you want to support min
HTTP/2 then create a config value on the server: MinHttpVersion = 2
I don't know why you are doing this but seems like a strange requirement and you may run into some SEO related issues:
Bots/Crawlers: you need to differentiate users from crawlers. Crawlers don't necessarily use a flash browser and this way, you may end up blocking them. You need to detect crawlers and exclude them from any version requirement.
Redirection to error page: This is not an error situation and should not be redirected to an error page. The redirect is a poor user experience (increases the page load time) and will cost your website in SEO ranking.
It is not clear why you want to do this? I suspect you don't want to support older browsers? If that's the case, then the common approach is to check user's browser version. For example this is what happens when you open Stackoverflow in IE:
So, you need to decide what is the minimum version for each browser that you want to support. Then you need to detect user's browser and if it's too old show an "outdated browser" message (do not redirect to an error page) and make sure you exclude crawlers.
You can do this both on the server and client side. This library might give you some ideas.