protected void Page_Load(object sender, EventArgs e)
    {
        string userAgentText;
        bool   runFromChecker = false;

        userAgent.Text = HttpUtility.HtmlEncode(Request.UserAgent);

        if (Request.QueryString["realversion"] != null)
        {
            userAgentText  = this.Request.QueryString["realversion"];
            runFromChecker = true;
        }
        else
        {
            userAgentText = this.Request.UserAgent;
        }

        UpdateInformationResponse response = Helpers.GetUpdateInformation(userAgentText, this.Request.Browser.ClrVersion);

        userResult.Text      = response.Text;
        developerOnline.Text = String.Format(@"If your users have internet connectivity, the .NET Framework is only between {1} and {2} megs. Why such a wide range? Well, it depends on if they already have some version of .NET.
         If you point your users to the online setup for the {0}, that {3} MB download will automatically detect and download the smallest archive possible to get the job done.", Constants.DotNetOnline, Constants.DotNetOfflineMB - Constants.Version3OfflineMB, Constants.DotNetOfflineMB, Constants.DotNetOnlineMB);

        developerOfflineResult.Text = String.Format(@"If you are a developer and are distributing your code on CD or DVD, you might want to download the 
         {0} on your media. The download is about {1} MB", Constants.DotNetOffline, Constants.DotNetOfflineMB);
        getdotnet.Visible           = response.VersionCanBeDetermined;
        checkdotnet.Visible         = response.CanRunCheckApp;

        // Hide the 4.5 checker section if
        // (a) we can't determine the dotnet version or
        // (b) we're on an OS that doesn't support .Net or
        // (c) the user has already run the checker so we know exactly what version they're on.
        // Note that the checkdotnet section in the header will still be displayed as long as the OS supports it
        dotnet45.Visible = response.VersionCanBeDetermined && response.CanRunCheckApp && !runFromChecker;
    }
Ejemplo n.º 2
0
    public static UpdateInformationResponse GetUpdateInformation(string UserAgent, string realVersion, int releaseKey)
    {
        bool   net4          = false;
        string netInfoString = "";
        var    response      = new UpdateInformationResponse();

        // We should check this first since we don't need to check .NET versions if they can't have .NET versions
        // Check for windows phone first as it may contain 'Mac' in User Agent
        if (UserAgent.Contains("Windows Phone"))
        {
            response.Text = "It looks like you're running a Windows Phone, awesome! There's no .NET Framework download for the Windows phone, but you might check out <a href=\"https://dev.windows.com/\"/>the Windows Dev Center</a> or <a href=\"http://www.windowsphone.com/store/\"/>the Windows Phone Store</a>";
            return(response);
        }
        if (UserAgent.Contains("Mac"))
        {
            response.Text = "It looks like you're running a Mac or an iPhone. There's no .NET Framework download from Microsoft for the Mac, but you might check out <a href=\"http://www.go-mono.com/mono-downloads/download.html\">Mono</a>, which is an Open Source platform that can run .NET code on a Mac. For your mobile devices, check out <a href=\"http://xamarin.com/platform\">Xamarin</a> and write .NET apps for iOS and Android!";
            return(response);
        }
        if (UserAgent.Contains("nix"))
        {
            response.Text = "It looks like you're running a Unix machine. There's no .NET Framework download from Microsoft for Unix, but you might check out <a href=\"http://www.go-mono.com/mono-downloads/download.html\">Mono</a>, which is an Open Source platform that can run .NET code on Unix.";
            return(response);
        }

        response.CanRunCheckApp         = true;
        response.VersionCanBeDetermined = true;

        net4 = GetWindows8Or10Message(UserAgent, ref netInfoString) || Get40Message(UserAgent, ref netInfoString);
        if (!string.IsNullOrEmpty(realVersion) || releaseKey != 0)
        {
            netInfoString = GetRealVersionMessage(ref realVersion, releaseKey);
        }
        else if (Helpers.Has35(UserAgent) || Helpers.Has35SP1C(UserAgent) || Helpers.Has35SP1E(UserAgent))
        {
            netInfoString += DotNet3_5Message((Helpers.Has35SP1C(UserAgent) || Helpers.Has35SP1E(UserAgent)), net4);
        }
        else if (Helpers.Has30(UserAgent))
        {
            netInfoString += DotNet3Message(net4);
        }
        else if (Helpers.Has20(UserAgent))
        {
            netInfoString += DotNet2Message(net4);
        }
        else if (Helpers.Has11(UserAgent) || Helpers.Has10(UserAgent))
        {
            netInfoString += DotNet1Message(net4);
        }
        else if (!net4)
        {
            if (UserAgent.Contains("fox"))
            {
                netInfoString += MessageForBrowser("Firefox");
            }
            else if (UserAgent.Contains("Chrome"))
            {
                netInfoString += MessageForBrowser("Chrome");
            }
            else if (UserAgent.Contains("Safari")) // Chrome also uses safari in the user agent so this check must come after
            {
                netInfoString += MessageForBrowser("Safari");
            }
            else
            {
                netInfoString += UnknownBrowserMessage();
            }

            response.VersionCanBeDetermined = false;
        }

        if (response.VersionCanBeDetermined)
        {
            response.VersionIsLatest = Helpers.CheckVersionLatest(realVersion, ref netInfoString);
        }

        //need to see if windows 2000 has the latest version
        foreach (KeyValuePair <string, string> windowsVersion in Constants.OldWindows)
        {
            netInfoString += CheckDotNet3_5UnSupportedOs(UserAgent, windowsVersion.Key, windowsVersion.Value);
        }

        response.Text = netInfoString;
        return(response);
    }