Asp.net checks whether the system has a. Net Environment

Source: Internet
Author: User
How can I check if your system has a Microsoft. NET Framework installed?

As a web developer, you may ask an interesting question: is there a way to detect whether your machine has a. NET environment? The answer is, of course! (Otherwise, I will not write this article here.ArticleAnd you won't read it now: P ). This probe method is incredibly simple, and even a layman can easily master it!
When you install the. NET Framework, it not only adds a newProgramOn your PC, you have also changed the behavior of some existing programs. For example, it changes some items of the IE browser-it modifies the User-Agent information of your IE, so it includes the version information of the. NET Framework.
What am I talking about? Let's look at an example: Asp.net's web matrix project page, and then click the link: "Click here to see if you have the. NET Framework installed.". The following page will show you whether you have installed the. NET environment.
How did they do it? Let's take a look at what actually happens when you click the link:

check the highlighted line in the HTTP header:
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0 ;. net CLR 1.0.3705)
not installed. before the net environment, its content is " User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0) ". now ,. when the net environment is installed, it adds some extended information- net CLR 1.0.3705. This new content can be used to detect. Net frameworks in ASP/ASP + pages.
for example, you can write the following sentence in the page_load function on the page:
string a = request. servervariables ["http_user_agent"]; // obtain the header.
If (. indexof (". net CLR 1.0.3705 ") <0) // detection
{response. write (". net not ") ;}< br> else {response. write (". net to ") ;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.