How to check IIS installed or not in my
windows OS using C#.Net
The below C#
code will help you to know IIS installed in your system or not. Some time we
need to know IIS installed or not before installing any web application in the
local system. If installed means we don’t need to reinstall the IIS.
//Check IIS
Installed or Not in the system
private
static string
_iisRegKey = @"Software\Microsoft\InetStp";
public static bool
IISInstalled()
{
try
{
using
(RegistryKey iisKey = Registry.LocalMachine.OpenSubKey(_iisRegKey))
{
return
(int)iisKey.GetValue("MajorVersion")
>= 6;
}
}
catch
{
return
false;
}
}
Install IIS in command prompt
The below
command prompt code will help you to install the IIS in command prompt or in
C#.net application. The code will enable your IIS installation in the windows
OS. This will work in windows7 and later version of OS.
Create a
.Bat file and past the below code and run the batch file or directly run the
below command in the command prompt.
@ECHO
**********INSTALATION PROCESS STATED************
@ECHO
*****************************************
@ECHO
**********IIS STARTED************
start /w
pkgmgr
/iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;IIS-StaticContent;IIS-DefaultDocument;IIS-ASPNET;IIS-DirectoryBrowsing;IIS-HttpErrors;IIS-HttpRedirect;IIS-ApplicationDevelopment;IIS-NetFxExtensibility;IIS-ASP;IIS-ISAPIExtensions;IIS-ISAPIFilter;IIS-HealthAndDiagnostics;IIS-HttpLogging;IIS-LoggingLibraries;IIS-RequestMonitor;IIS-HttpTracing;IIS-CustomLogging;IIS-Security;IIS-WindowsAuthentication;IIS-WebServerManagementTools;IIS-IIS6ManagementCompatibility;IIS-LegacyScripts;IIS-LegacySnapIn;IIS-Metabase;IIS-WMICompatibility;IIS-RequestFiltering;IIS-IPSecurity;IIS-Performance;IIS-HttpCompressionStatic;IIS-WebServerManagementTools;IIS-IIS6ManagementCompatibility;IIS-ManagementConsole;IIS-ManagementScriptingTools;IIS-ManagementService;WAS-WindowsActivationService;WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI;
@ECHO
**********IIS COMPLETED************
@ECHO
*****************************************
@ECHO
**********INSTALLATION COMPLETED SUCCESSFULLY************
Run web application as administrator writes
in IIS.
Some time we
need to run our web application as administrator mode. One of my application
run time I want to create some file in my web application. While creating the
txt file in my root folder in c drive C:\inetpub\wwwroot I got security
exception error. The reason is I don’t have administrator permission to write
text file in my application. For that I have added the Identity impersonate is
TRUE in the web config file.
<system.web>
<identity impersonate="true" userName="sa" password="pwd"/>
No comments:
Post a Comment