Debugging Web Applications in IIS Express

    iis7For those who do not want to wait for the official support of IIS Express in Visual Studio, there is an easy way to tighten the debugging option yourself.

    All we need is to download WebMatrix beta , which includes IIS Express (there is no separate download yet).



    We put IIS Express


    After installing WebMatrix, we find and edit the file "My Documents \ IISExpress8 \ config \ applicationhost.config".
    Go to the 145th line and create another site definition in the image and likeness of WebSite1, removing the serverAutoStart attribute:
    Copy Source | Copy HTML
    1.     
    2.         
    3.     
    4.     
    5.         
    6.     
    7.     
    8.         
    9.     
    10.     
    11.         
    12.     

    I think the values ​​of the changed attributes are obvious, so skip their description.
    It is time to start our server. You can do this with the following command:

    "C:\Program Files (x86)\Microsoft WebMatrix\iisexpress.exe" /site:{YOUR_SITE_NAME}

    Instead of {YOUR_SITE_NAME} you need to substitute the name of your site that you specified in applicationhost.config. In my case, this is VSDebug. If everything is done correctly, the server will start and your site will be available.

    Customize Visual Studio


    We launch the studio and upload our website to it. Right-click on the project, select Properties and go to the Web tab. Here we need to select the Start External Program and specify the command to start our server. Below, in the same window, select Use Custom Web Server and enter the site URL again. In the Debuggers section, uncheck all the boxes, because the studio will try to attach to IIS and will not allow us to debug. Now save the properties and press F5 to start debugging. You can open the site in a browser using the IIS Express tray icon. PS The following Kamran Ayub article motivated me to describe this process . However, I think that the method described by me is somewhat simpler and eliminates the need to manually restart the server and attach to it.

















    Also popular now: