The ASP.NET detection system is installed .NET environment

xiaoxiao2021-03-06  53

How to detect if your system is installed with a Microsoft .NET framework? As a web developer, you may ask such a interesting question: Is there a way to detect your machine whether it is installed ?NET environment? The answer is, of course! (Otherwise, I will not write this article here, you will not read it now: P). This detection method is amazing and simple, and even the outside is easy to master! When you install the .NET framework, it's not just adding a new program on your PC, and also changed some behavior of the program. For example, it changed some of the IE browser - it modified the user-agent of your IE, so it included the version information of the .NET framework. What am I talking? We can go see an example: ASP.NET'S Web Matrix Project Page, then click the link: "Click Here to See if You Have the.net framework installed.". Then the following page will tell you if you have a .NET environment. How did they do? Let's take a look at what happened when you click on the link: see this highlighted line in the HTTP header: user-agent: mozilla / 4.0 (compatible; msie 6.0; windows NT 5.0; .NET CLR 1.0.3705 Before the .NET environment is not installed, its content is "User-Agent: Mozilla / 4.0 (Compatible; Msie 6.0; Windows NT 5.0)". Now, .NET environment is installed, it has more extension information - -NET CLR 1.0.3705. This new content can be used to detect the .NET framework in the ASP / ASP page. For example, you can write as follows in the page Page_Load function: string a = request.servervariables ["http_user_agent"]; // Number of head IF (A.indexof (". Net CLR 1.0.3705") <0) // Detect {response.write (". Net is wrong");} else {response.write (". Net pair");}

转载请注明原文地址:https://www.9cbs.com/read-113617.html

New Post(0)