Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting to Visual Studio debugging IIS Express server over the lan

I have a test ASP.NET MVC3 application developed in VS2012. When I start debugging the app is accessed from the host machine via the request to http://localhost:<portnumber>. But if I try to access the same application from the remote machine in the intranet via the http://<ip>:<portnumber> I get HTTP error 400: Bad request. Invalid Host Name. As far as it runs on IIS Express any server configuration is inaccessible.

Are there any ways of solving this?

like image 701
gator88 Avatar asked Feb 06 '13 09:02

gator88


People also ask

How do I access my IIS Express site from another computer?

Normally when you run an application in IIS Express, it's only accessible on http://localhost:[someport]. In order to access it from another machine, it needs to be bound to your public IP address as well. Open* D:\Users[YourName]\Documents\IISExpress\config\applicationhost. config *and find your site.

How do I debug IIS from Visual Studio?

In the Visual Studio toolbar, make sure the configuration is set to Debug, and either IIS Express, or the new IIS profile name, appears in the emulator field. To start debugging, select IIS Express or <IIS profile name> in the toolbar, select Start Debugging from the Debug menu, or press F5.

How do I use Visual Studio with IIS Express?

Configure IIS express on visual studioSelect the web application project and open properties -> select the web tab -> under server's select IIS express-> Specify the project URL. Now open the project folder and . vs folder (Hidden) -> Config -> applicationhost.

How do I connect debugger to remote IIS?

If you are planning to attach to a process which is running as an administrator, or is running under a different user account (such as IIS), right-click the Remote Debugger app and select Run as administrator. For more information, see Run the remote debugger as an administrator.


1 Answers

Update

I made a video that better describes the process, https://youtu.be/5ZqDuvTqQVs

If you are using Visual Studio 2013 or above, make sure you run it as an administrator for this to work.


Open the %USERPROFILE%\My Documents\IISExpress\config\applicationhost.config (in VS2015 it may be $(solutionDir)\.vs\config\applicationhost.config) file. Inside you should see something like this:
<site name="WebSite1" id="1" serverAutoStart="true">     <application path="/">         <virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite1" />     </application>     <bindings>         <binding protocol="http" bindingInformation="*:8080:localhost" />     </bindings> </site> 

Change the bindingInformation=":8080:localhost" to bindingInformation="*:8080:*" (the port number, 8080 in my case, will differ.)

Note: If it does not work try with bindingInformation="*:8080: the asterix can be removed.

Then make sure your firewall is allowing incoming connections on that port. You may need to restart the system or at least Visual Studio to get IISExpress to reload the config file.

If this doesn't work, take a look at this answer: https://stackoverflow.com/a/5186680/985284

like image 179
Garrett Fogerlie Avatar answered Sep 26 '22 13:09

Garrett Fogerlie