Thursday, May 5, 2011

Portable IIS : IIS Express 7.5

I have wanted a portable IIS since the first time I had to configure IIS to use asp.net :)
And that dream has come true with IIS 7.5 Express : http://www.microsoft.com/downloads/en/details.aspx?FamilyID=abc59783-89de-4adc-b770-0a720bb21deb

Unlike other express softwares IIS 7.5 is a complete version. Just more portable :)

I didn't know that I could get the server without webmatrix and that is the reason I am blogging about it (Download link for offline installation of IIS Express here same as mentioned above).

After you download it just install it. It is 32 bit version only. But that means that you can xcopy deploy your server + websites. Great for silverlight portable deployment scenario :)

Where does it get its websites?
By default IIS Express will load websites as folders from the current users "My documents folder", You can get this information by giving an invalid URL (Note the Physical Path):

Where does it gets its configuration to look for websites? 
This one was harder to answer. I needed to open process monitor to figure it out as shown:
And therein:

The command line options:
You can get a complete list of IIS Express from the command line as follows :
iisexpress.exe /h
Most important command line switches are options: 
/config
/systray:true|false
/port

Finally: Getting IIS Express to run portably: 
Two things need to be done here :


1.) Setting IISExpress to use config from the same folder as IISExpress and not user folder: 
I copied everything from "C:\Users\Basiee\Documents\IISExpress" to "%IIS_BIN%\User"

2.) Configuring the log files + websites to run from IIS_BIN
Just open applicationhost.config and configure your website as so:
Note I changed the website name. And modified the path for PhysicalPath / logfile and trace files



Now you can run IIS Express using the following command line: 
iisexpress /config:./USER/config/applicationhost.config




More?
To learn everything in more detail visit : http://learn.iis.net/page.aspx/860/iis-express/

Enjoy! 

9 comments:

  1. Very good. I just needed this. Thank you.

    ReplyDelete
  2. Basarat

    Were you able to get the system tray application to run correctly when you did the steps above?

    I have tried twice and it seems both times the tray app does not automatically fire up as it does when running from the original install directories.

    Any thoughts?

    ReplyDelete
  3. No I wasn't. But I didn't try too hard to figure out why.

    ReplyDelete
  4. An error occured while reading configuration information. Check that the configuration file exists, is well formed, and contains valid configuration information.

    This is the error I get... can you help me?

    ReplyDelete
  5. Awesome! I'm working making an online Silverlight App work offline. I want to create a WPF app to launch the site in IIS Express. Any idea how to get the variables - %IIS_BIN% at runtime / in the code?

    ReplyDelete
    Replies
    1. System.Environment.GetEnvironmentVariable()? But will only work if the user actually manually sets the variable on his system. No idea otherwise.

      Delete
  6. Know of a way to get the %IIS_BIN% variable from code?

    ReplyDelete
  7. This is not portable anything. You need to have Administrative privileges to install it. I get this error:

    "Administrator privilege is required to install IIS 7.5 Express."

    ReplyDelete
  8. Hi,

    I am very new to using IIS express (have worked previously with standard IIS), I am trying to get an existing web application that runs via IIS on a web server using the application pool.

    The set up of the existing server is that it uses one application pool which loads two applications appname appnameCore With a physical path like

    C:\inetpub\wwwroot\appname\applications\appname C:\inetpub\wwwroot\appname\applications\appnameCore

    It is a Silverlight based application.

    Currently the application uses an MS SQL database but I would like to change this to MS SQL CE I am not quite sure how to set up the same sort of environment, at the moment I have the web server running from a pen stick (memory stick/drive) and I would like to make the application portable. IIS Express is running from the Pen Drive fine at the moment but I am not sure how to configure the app pools.

    I think I am also right in saying MS SQL CE uses .sdf instead of .mdf for databases, how can I make an existing .mdf database into the right format?

    I think it is possible but I have have got stuck with the how to after trying for quite some time.

    I would really appreciate any help you can give me.

    If I can give any more information or expand the question in some way please let me know.

    Thanks, Glenn :)

    ReplyDelete