Does anyone have a bulletproof method (in C# ideally!) of determining if ASP.Net is properly registered on your computer ?
I am writing an installation program for an ASP.Net application and I need to know whether I should run aspnet_regiis
.
At the moment we always run aspnet_regiis
- I to ensure that ASP.Net is registered properly but this undesirable because it prompts a restart of all the application pools.
There are several useful pages on the web (e.g. http://www.codeproject.com/KB/cs/iisdetection.aspx) but as the comments in that post show, it is quite often the case that the registry reports that ASP.Net is registered but aspnet_regiis
still needs to be run to configure IIS. The user 'JonB' posted something that looks like it should work for IIS6 (and IIS7 with IIS6 compatibility enabled) but I would still need to write separate detection code for IIS 7 with IIS6 compatibility mode disabled.
So has anyone cracked this nut already? If so please let us know as it will be a time saver. Otherwise I will try and port the C++ solution into C# for IIS6 and for IIS7 I will look examine the <isapiCgiRestriction>
section of applicationHosts.config
for
<add path="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" allowed="true" groupId="ASP.NET v2.0.50727" description="ASP.NET v2.0.50727" />
Last question...
Does anyone know if things are the same/different in Windows 7?
Click Start > Control Panel > Administrative Tools > Internet Information Services (IIS) Manager. On the left pane, expand the entry for Local Computer and click Web Service Extensions. Check that there is an item called ASP.NET v2. 0.50727 and that its status reads Allowed .
If ASP.NET 3.5 or 4.5 are installed, in the list of Roles they will be located under Web Server (IIS) > Web Server > Application Development.
First, you should to determine if . NET 3.5 is installed by looking at HKLM\Software\Microsoft\NET Framework Setup\NDP\v3. 5\Install, which is a DWORD value. If that value is present and set to 1, then that version of the Framework is installed.
Open the Control Panel, click "Programs" and then click "Turn Windows features on or off" to open the "Windows Features" dialog. 2. Enable ". NET Framework 4.5 Advanced Services > ASP.NET 4.5" (version 4.6 in Windows 10):
First I would try running aspnet_regiis -lv
. This should give you an output like:
1.1.4322.0 Valid C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll 2.0.50727.0 Valid c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll
that you can easily parse to verify that your target version is installed and valid. If it is not, you'll have to go the aspnet_regiis -i
route.
Also, given that you can do this check in C#, you could add a test page to your ASP.NET application. After what you would normally consider a successful installation, do a HttpWebRequest
on that test page. The page itself can be as simple as an empty page and as complicated as running a self-check of the installation (file/folder permissions, DB configuration, etc.) and would only return a HTTP 200 if everything is ok. Any timeout or error indicates a bad install. Then,optionally, delete the test page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With