📜 ⬆️ ⬇️

Debugging Web Applications in IIS Express

iis7 For those who do not want to wait for the official support of IIS Express in Visual Studio, there is an easy way to fix the possibility of debugging 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 similarity of WebSite1, removing the serverAutoStart attribute:
Copy Source | Copy HTML < site name ="WebSite1" id ="1"> < application path ="/"> < virtualDirectory path ="/" physicalPath ="%IIS_SITES_HOME%\WebSite1" /> </ application > < bindings > < binding protocol ="http" bindingInformation =":8080:localhost" /> </ bindings > </ site > < site name ="VSDebug" id ="2"> < application path ="/" applicationPool ="Clr4IntegratedAppPool"> < virtualDirectory path ="/" physicalPath ="c:\dev\mysite" /> </ application > < bindings > < binding protocol ="http" bindingInformation =":8421:localhost" /> </ bindings > </ site >
  1. Copy Source | Copy HTML < site name ="WebSite1" id ="1"> < application path ="/"> < virtualDirectory path ="/" physicalPath ="%IIS_SITES_HOME%\WebSite1" /> </ application > < bindings > < binding protocol ="http" bindingInformation =":8080:localhost" /> </ bindings > </ site > < site name ="VSDebug" id ="2"> < application path ="/" applicationPool ="Clr4IntegratedAppPool"> < virtualDirectory path ="/" physicalPath ="c:\dev\mysite" /> </ application > < bindings > < binding protocol ="http" bindingInformation =":8421:localhost" /> </ bindings > </ site >
  2. Copy Source | Copy HTML < site name ="WebSite1" id ="1"> < application path ="/"> < virtualDirectory path ="/" physicalPath ="%IIS_SITES_HOME%\WebSite1" /> </ application > < bindings > < binding protocol ="http" bindingInformation =":8080:localhost" /> </ bindings > </ site > < site name ="VSDebug" id ="2"> < application path ="/" applicationPool ="Clr4IntegratedAppPool"> < virtualDirectory path ="/" physicalPath ="c:\dev\mysite" /> </ application > < bindings > < binding protocol ="http" bindingInformation =":8421:localhost" /> </ bindings > </ site >
  3. Copy Source | Copy HTML < site name ="WebSite1" id ="1"> < application path ="/"> < virtualDirectory path ="/" physicalPath ="%IIS_SITES_HOME%\WebSite1" /> </ application > < bindings > < binding protocol ="http" bindingInformation =":8080:localhost" /> </ bindings > </ site > < site name ="VSDebug" id ="2"> < application path ="/" applicationPool ="Clr4IntegratedAppPool"> < virtualDirectory path ="/" physicalPath ="c:\dev\mysite" /> </ application > < bindings > < binding protocol ="http" bindingInformation =":8421:localhost" /> </ bindings > </ site >
  4. Copy Source | Copy HTML < site name ="WebSite1" id ="1"> < application path ="/"> < virtualDirectory path ="/" physicalPath ="%IIS_SITES_HOME%\WebSite1" /> </ application > < bindings > < binding protocol ="http" bindingInformation =":8080:localhost" /> </ bindings > </ site > < site name ="VSDebug" id ="2"> < application path ="/" applicationPool ="Clr4IntegratedAppPool"> < virtualDirectory path ="/" physicalPath ="c:\dev\mysite" /> </ application > < bindings > < binding protocol ="http" bindingInformation =":8421:localhost" /> </ bindings > </ site >
  5. Copy Source | Copy HTML < site name ="WebSite1" id ="1"> < application path ="/"> < virtualDirectory path ="/" physicalPath ="%IIS_SITES_HOME%\WebSite1" /> </ application > < bindings > < binding protocol ="http" bindingInformation =":8080:localhost" /> </ bindings > </ site > < site name ="VSDebug" id ="2"> < application path ="/" applicationPool ="Clr4IntegratedAppPool"> < virtualDirectory path ="/" physicalPath ="c:\dev\mysite" /> </ application > < bindings > < binding protocol ="http" bindingInformation =":8421:localhost" /> </ bindings > </ site >
  6. Copy Source | Copy HTML < site name ="WebSite1" id ="1"> < application path ="/"> < virtualDirectory path ="/" physicalPath ="%IIS_SITES_HOME%\WebSite1" /> </ application > < bindings > < binding protocol ="http" bindingInformation =":8080:localhost" /> </ bindings > </ site > < site name ="VSDebug" id ="2"> < application path ="/" applicationPool ="Clr4IntegratedAppPool"> < virtualDirectory path ="/" physicalPath ="c:\dev\mysite" /> </ application > < bindings > < binding protocol ="http" bindingInformation =":8421:localhost" /> </ bindings > </ site >
  7. Copy Source | Copy HTML < site name ="WebSite1" id ="1"> < application path ="/"> < virtualDirectory path ="/" physicalPath ="%IIS_SITES_HOME%\WebSite1" /> </ application > < bindings > < binding protocol ="http" bindingInformation =":8080:localhost" /> </ bindings > </ site > < site name ="VSDebug" id ="2"> < application path ="/" applicationPool ="Clr4IntegratedAppPool"> < virtualDirectory path ="/" physicalPath ="c:\dev\mysite" /> </ application > < bindings > < binding protocol ="http" bindingInformation =":8421:localhost" /> </ bindings > </ site >
  8. Copy Source | Copy HTML < site name ="WebSite1" id ="1"> < application path ="/"> < virtualDirectory path ="/" physicalPath ="%IIS_SITES_HOME%\WebSite1" /> </ application > < bindings > < binding protocol ="http" bindingInformation =":8080:localhost" /> </ bindings > </ site > < site name ="VSDebug" id ="2"> < application path ="/" applicationPool ="Clr4IntegratedAppPool"> < virtualDirectory path ="/" physicalPath ="c:\dev\mysite" /> </ application > < bindings > < binding protocol ="http" bindingInformation =":8421:localhost" /> </ bindings > </ site >
  9. Copy Source | Copy HTML < site name ="WebSite1" id ="1"> < application path ="/"> < virtualDirectory path ="/" physicalPath ="%IIS_SITES_HOME%\WebSite1" /> </ application > < bindings > < binding protocol ="http" bindingInformation =":8080:localhost" /> </ bindings > </ site > < site name ="VSDebug" id ="2"> < application path ="/" applicationPool ="Clr4IntegratedAppPool"> < virtualDirectory path ="/" physicalPath ="c:\dev\mysite" /> </ application > < bindings > < binding protocol ="http" bindingInformation =":8421:localhost" /> </ bindings > </ site >
  10. Copy Source | Copy HTML < site name ="WebSite1" id ="1"> < application path ="/"> < virtualDirectory path ="/" physicalPath ="%IIS_SITES_HOME%\WebSite1" /> </ application > < bindings > < binding protocol ="http" bindingInformation =":8080:localhost" /> </ bindings > </ site > < site name ="VSDebug" id ="2"> < application path ="/" applicationPool ="Clr4IntegratedAppPool"> < virtualDirectory path ="/" physicalPath ="c:\dev\mysite" /> </ application > < bindings > < binding protocol ="http" bindingInformation =":8421:localhost" /> </ bindings > </ site >
  11. Copy Source | Copy HTML < site name ="WebSite1" id ="1"> < application path ="/"> < virtualDirectory path ="/" physicalPath ="%IIS_SITES_HOME%\WebSite1" /> </ application > < bindings > < binding protocol ="http" bindingInformation =":8080:localhost" /> </ bindings > </ site > < site name ="VSDebug" id ="2"> < application path ="/" applicationPool ="Clr4IntegratedAppPool"> < virtualDirectory path ="/" physicalPath ="c:\dev\mysite" /> </ application > < bindings > < binding protocol ="http" bindingInformation =":8421:localhost" /> </ bindings > </ site >
  12. Copy Source | Copy HTML < site name ="WebSite1" id ="1"> < application path ="/"> < virtualDirectory path ="/" physicalPath ="%IIS_SITES_HOME%\WebSite1" /> </ application > < bindings > < binding protocol ="http" bindingInformation =":8080:localhost" /> </ bindings > </ site > < site name ="VSDebug" id ="2"> < application path ="/" applicationPool ="Clr4IntegratedAppPool"> < virtualDirectory path ="/" physicalPath ="c:\dev\mysite" /> </ application > < bindings > < binding protocol ="http" bindingInformation =":8421:localhost" /> </ bindings > </ site >
  13. Copy Source | Copy HTML < site name ="WebSite1" id ="1"> < application path ="/"> < virtualDirectory path ="/" physicalPath ="%IIS_SITES_HOME%\WebSite1" /> </ application > < bindings > < binding protocol ="http" bindingInformation =":8080:localhost" /> </ bindings > </ site > < site name ="VSDebug" id ="2"> < application path ="/" applicationPool ="Clr4IntegratedAppPool"> < virtualDirectory path ="/" physicalPath ="c:\dev\mysite" /> </ application > < bindings > < binding protocol ="http" bindingInformation =":8421:localhost" /> </ bindings > </ site >
  14. Copy Source | Copy HTML < site name ="WebSite1" id ="1"> < application path ="/"> < virtualDirectory path ="/" physicalPath ="%IIS_SITES_HOME%\WebSite1" /> </ application > < bindings > < binding protocol ="http" bindingInformation =":8080:localhost" /> </ bindings > </ site > < site name ="VSDebug" id ="2"> < application path ="/" applicationPool ="Clr4IntegratedAppPool"> < virtualDirectory path ="/" physicalPath ="c:\dev\mysite" /> </ application > < bindings > < binding protocol ="http" bindingInformation =":8421:localhost" /> </ bindings > </ site >
  15. Copy Source | Copy HTML < site name ="WebSite1" id ="1"> < application path ="/"> < virtualDirectory path ="/" physicalPath ="%IIS_SITES_HOME%\WebSite1" /> </ application > < bindings > < binding protocol ="http" bindingInformation =":8080:localhost" /> </ bindings > </ site > < site name ="VSDebug" id ="2"> < application path ="/" applicationPool ="Clr4IntegratedAppPool"> < virtualDirectory path ="/" physicalPath ="c:\dev\mysite" /> </ application > < bindings > < binding protocol ="http" bindingInformation =":8421:localhost" /> </ bindings > </ site >
  16. Copy Source | Copy HTML < site name ="WebSite1" id ="1"> < application path ="/"> < virtualDirectory path ="/" physicalPath ="%IIS_SITES_HOME%\WebSite1" /> </ application > < bindings > < binding protocol ="http" bindingInformation =":8080:localhost" /> </ bindings > </ site > < site name ="VSDebug" id ="2"> < application path ="/" applicationPool ="Clr4IntegratedAppPool"> < virtualDirectory path ="/" physicalPath ="c:\dev\mysite" /> </ application > < bindings > < binding protocol ="http" bindingInformation =":8421:localhost" /> </ bindings > </ site >

I think the values ​​of the changed attributes are obvious, so let's skip their description.
It's 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 start studio and load our site into 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 re-enter the site URL.



In the Debuggers section, remove all the checkboxes, 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 the browser using the IIS Express tray icon.



PS The following article by Kamran Ayub led me to the description of this process. However, I think that the method described by me is somewhat easier and eliminates the need to restart the server with hands and attach to it.

Source: https://habr.com/ru/post/100975/


All Articles