Saturday, 9 June 2018

IIS Logging- Enable IIS Logging using Command Prompt


IIS Logging




C:\Users\aditya.chouhan>%systemroot%\System32\inetsrv\appcmd.exe set site FbSa-Bell.Ca 
/logfile.enabled:true
/logfile.directory:"C:\inetpub\logs\LogFiles"
/logfile.logformat:W3C
SITE object "FbSa-Bell.Ca" changed




Exporting and Importing Sites and App Pools from IIS Server


Exporting and Importing Sites and App Pools from IIS 7 and 7.5
When using multiple IIS server in a Load Balanced Environment it will  be alot of work to create all your website twice with the same settings on each webserver. Therefor it is possible to export and import your configuration from one webserver to the other. This will also be usefull when your upgrading from IIS 7 (Windows Server 2008) to IIS 7.5 (Windows Server 2008 R2).
When you create a website in IIS 7 or 7.5 a unique application pool will also be created and used by this website, that’s why you need to import these application pools first on the second webserver before importing the website(s).
To Export the Application Pools on IIS 7 :
Results:-
Command:-
%windir%\system32\inetsrv\appcmd list apppool /config /xml > c:\apppools.xml (WORKED).
This will export all the application pools on your webserver, therefor you need to edit the apppools.xml and remove the application that you do not need to import for example:
  • DefaultAppPool
  • Classic .NET AppPool
  • SecurityTokenServiceApplicationPool
And other apppools that already exist on the second webserver, appcmd doesn’t skip already existing apppools, it just quit’s and doesn’t import any.



àTo import the Application Pools:
%windir%\system32\inetsrv\appcmd add apppool /in < C:\Apppools.xml
All the AppPools in the xml will be created on your second webserver.


àTo Export all your website:
%windir%\system32\inetsrv\appcmd list site /config /xml > c:\sites.xml
This will export all the websites on your webserver, therefor you need to edit the sites.xml and remove the websites that you do not need to import for example:
  • Default Website
And all other websites that already exist on the second webserver.


àTo Import the website:
%windir%\system32\inetsrv\appcmd add site /in < c:\sites.xml
It’s also possible to export a single website or application pool all you need to do is add the name of the Application Pool or Website to the command line:
àTo export/import a single application pool:
%windir%\system32\inetsrv\appcmd list apppool “MyAppPool” /config /xml > c:\myapppool.xml
àImport:
%windir%\system32\inetsrv\appcmd add apppool /in < c:\myapppool.xml
àTo export/import a single website:
%windir%\system32\inetsrv\appcmd list site “MyWebsite” /config /xml > c:\mywebsite.xml
Import:
%windir%\system32\inetsrv\appcmd add site /in < c:\mywebsite.xml

What is ISAPI Filters & Extensions


     
ISAPI (Internet Server Application Program Interface) is a set of Windows program calls that let you write a Web server application that will run faster than a common gateway interface (CGI) application. A disadvantage of a CGI application (or "executable file," as it is sometimes called) is that each time it is run, it runs as a separate process with its own address space, resulting in extra instructions that have to be performed, especially if many instances of it are running on behalf of users.

Using ISAPI, you create a dynamic link library (DLL) application file that can run as part of the Hypertext Transport Protocol (HTTP) application's process and address space. The DLL files are loaded into the computer when HTTP is started and remain there as long as they are needed; they don't have to be located and read into storage as frequently as a CGI application.

A special kind of ISAPI DLL is called an ISAPI filter, which can be designated to receive control for every HTTP request. You can create an ISAPI filter for encryption or decryption, for logging, for request screening, or for other purposes.




By Default Path:-
 C:\Windows\Microsoft.NET\Framework\v4.0.30319\\aspnet_filter.dll’ could not be loaded due to a configuration problem
How to install ISAPI Filter and Extension:-

WINDOWS SERVER 2008 OR WINDOWS SERVER 2008 R2

1.       On the taskbar, click Start, point to Administrative Tools, and then click Server Manager.
2.       In the Server Manager hierarchy pane, expand Roles, and then click Web Server (IIS).
3.       In the Web Server (IIS) pane, scroll to the Role Services section, and then click Add Role Services.
4.       On the Select Role Services page of the Add Role Services Wizard, select ISAPI Filters, and then click Next.

5.       On the Confirm Installation Selections page, click Install.
6.       On the Results page, click Close.



Friday, 8 June 2018

IIS Server Questions and Answers



    What do you mean by recycling an Application Pool :à
ð  Answer:
An Application Pool is, in short, a region of memory that is maintained up and running by a process called W3WP.exe, aka Worker Process.
Recycling an Application Pool means bringing that process down, eliminating it from memory and then originating a brand new Worker Process, with a newly assigned process ID”
Global IIS settings changes may require Application Pool recycle (killing and starting a new Worker Process, W3WP.exe)

2.       What do you mean by restarting an App Domain?
ð  Answer:
Restarting a App Domain means starting over a given application with the newly added settings, such as refreshing the existing configuration.
That happens within the boundaries of that sub-region of memory, called AppDomain that ultimately lies within the process associated with a respective Application Pool.
Causes of an application domain recycle
The following circumstances will cause a recycle of an application domain:
  • Modification to web.config or Global.asax.
  • Change to the contents of the application's bin directory.
  • Change to the physical path of the virtual directory.
  • Deletion of the subdirectory of the application.
  • The number of re-compilations (aspx, ascx or asax) exceeds the limit specified by the <compilation numRecompilesBeforeAppRestart=/> setting in machine.config or web.config (default of 15).




3.      How to stop, start, or restart the IIS Admin Service?

ð  Answer:

You may need to stop the IIS Admin Service when installing or updating the software. The IIS Admin Service is used to publish websites on the machine; to avoid web outages, stop the service at non-peak website times. This will affect all IIS-dependent services.
1.      Click Start, Settings, Control Panel, Administrative Tools. 
2.      Open Services. 
3.      Right-click on the IIS Admin Service and select Stop, Start, or Restart.
Note: If you receive an error when manually stopping IIS, reboot  the machine and attempt to manually stop IIS again.


 From a command prompt:
1.      Type NET STOP IISADMIN and press Enter. 
2.      Once the service has stopped, type NET START IISADMIN and press Enter. 
3.      Type NET START W3svc and press Enter.




4.      Why we need Virtual Directory?


ð  Answer:
ð  In actual Virtual directories are a way to access folders which are not under the web site hierarchy.
A virtual directory represents a web application and it points to a physical folder in your computer.
A web application is accessed using a virtual directory name instead of a physical folder name.

For example, if you have a web application called "Shopcart" in your machine, you will have a virtual directory for this web application. You will access your web application using the URL httP://localhost/Shopcart.
If your virtaul directory name is "Test", then your web application url will be http://localhost/Test.

Assume you have a web application called "Shopcart", created under the physical folder "C:\MyProjects\Shopcart". 

You can go to IIS and see this virtual directory listed. Right click on this virtual directory name in IIS and see the properties. You can see that this virtual directory is pointing to the physical location "C:\MyProjects\Shopcart".

If you have a file called "File1.aspx" under the folder "C:\MyProjects\Shopcart\", then you can access this file using Internet Explorer with the URL "http://localhost/Shopcart/File1.aspx"

How to create a virtual directory ?

When you create a new web project using, a new virtual directory will be created automatically for you. This virtual directory will point to a new folder created under C:\Inetpub\wwwroot. 

If you like to better organize your projects and files in your favourite folder, you must manually create a new folder for each project in your preferred location and convert it into a virtual folder manually.

There are couple of ways you can do this.

Method 1: Open the IIS. Right click on the node "Default Web Site" and select "new Virtual Directory". When it prompt you to enter the "alias", enter the virtual directory name you want(Eg: Shopcart). In the prompt for "directory", select the folder which you want to make a virtual directory (Eg: C:\MyProjects\Shopcart). Select other default values and press "Finish". Now you should be able to see your new virtual directory in IIS.

Method 2: In the explorer, go to the folder(Eg: C:\MyProjects\Shopcart) which you want to make a "virtual directory". Right click on the folder name and select "Properties". Select the tab "Web sharing" and select teh option "Share this folder". It will prompt you with a default Alias name same as the folder name (Eg: Shopcart). Simply select the default values and press "OK".
5.       What is an IIS Structure?

ð  Answer:





IIS has 3 main components – http.sys, IIS admin Services, and worker processes (=Application Pools).

1. HTTP.SYS:-

This is a kernel component, which means it’s not a part of user mode processes, such as W3WP.EXE.

A kernel component never uses any virtual memory of user processes. It’s isolated & separated. 

HTTP.SYS has 3 important roles – (client) connection management, routing requests from browsers, and managing response cache.

: Routing requests means http.sys dispatches requests to the correct Application Pool Queue’ for each worker process.

2. Worker Processes (=Application Pools, w3wp.exe)
W3WP(WWW Worker Process) handles all the contents, aka, static contents, such as HTML/GIF/JPG files, and runs dynamic contents, such as ASP/ASP.NET applications. Therefore, the status of W3WP process(=Application Pool) is critical for the performance & stability of web applications, or web sites.

3. IIS Admin Services:-
Managing the above IIS components using IIS configurations as a Windows Service Management(SVCHost.exe).




6.      What is a command to run and see that which Worker Process’ ID is assigned to which App Pool?

èAnswer:
C:\Windows\System32\inetsrv>  %systemroot%\system32\inetsrv\APPCMD list wps



My Practical’s:


Ø  How to start appcmd.exe.?
Ø  We use “Iisapp.vbs” in IIS 6.0.
Answer: Copy and paste this command in cmd: cd %windir%\system32\inetsrv
Answer:  
  1. Open IIS Manager. For information about opening IIS Manager, see Open IIS Manager (IIS 7).
  2. In the Connections pane, expand the server node and click Application Pools.
  3. On the Application Pools page, click to select an application pool from the list.
  4. In the Actions paneclick Basic Settings.
  5. From the Managed pipeline mode list, select one of the following options:
    • Integrated, if you want to use integrated IIS and ASP.NET request-processing.
    • Classic, if you want to use IIS and ASP.NET request-processing modes separately.
  6. Click OK.




Command Line

To configure the managed request-processing pipeline mode for an application pool, use the following syntax:
appcmd set apppool /apppool.name: string /managedPipelineMode: Integrated|Classic
The variable string is the name of the application pool that you want to change, and the value that you specify for managedPipelineMode is the mode that IIS uses to process requests for managed code.
For example, to configure an application pool named Marketing to use Classic mode, type the following at the command prompt, and then press Enter:
appcmd set apppool /apppool.name: Marketing /managedPipelineMode:Classic










Comments System

Disqus Shortname