Showing posts with label Debug. Show all posts
Showing posts with label Debug. Show all posts

Tuesday, February 11, 2014

Enable Remote Requests To IIS Express

I ran into a situation where I had an issue with a web application that was isolated to the iPad running the latest OS. Using Safari's WebInspector functionality yielded nothing fruitful, so I looked to ways that I could debug the remote requests coming to my web application in visual studio.

I found a SharpProxy and IISExpressProxy, both ran, but neither worked. I stumbled upon a Hanselman blog post titled Working with SSL at Development Time is easier with IISExpress. The title wasn't very useful to my situation, however lack of other options pushed me on to reading further.

About a third of the way down there is a section called "Getting IIS Express to serve externally...". This peeked my interest and ended up being the key to what I was attempting to achieve.

The solution

Initially this did not work. I was able to run all of the commands, however I ended up having to restart Visual Studio to get the config to update.
The blog post has a bit of out dated information regarding the firewall command. Below is the command that worked for me. Run the following commands from the Developer Console in Administrator mode. Obviously you'll have to change the ComputerName and the port to your situation.
netsh http add urlacl url=http://ComputerName:58144/ user=everyone

netsh advfirewall firewall add rule name="IISExpressWeb" dir=in action=allow program="IISExpressWeb" enable=yes

"c:\Program Files (x86)\IIS Express\appcmd.exe" set site /site.name:Web1 /+bindings.[protocol='http',bindingInformation='*:58144:ComputerName']

"c:\Program Files (x86)\IIS Express\appcmd.exe" set site /site.name:Web1 /+bindings.[protocol='http',bindingInformation='*:58144:ComputerName.domain']
If the firewall line doesn't work, you may need to change the program="IISExpressWeb" to program="c:\Program Files (x86)\IIS Express\iisexpress.exe".

If you have Visual Studio open, restart it and make sure all instances of IIS Express are closed. If you don't want to run the application from Visual Studio, you can start IIS Express from the command line with (change Web1 to whatever the site name is for your web application):
"c:\Program Files (x86)\IIS Express\iisexpress.exe" /site:Web1
You should be able to access your website from your remote web browser.

Thursday, April 19, 2012

Attach Debugger To All Web Processes Using Powershell Inside Visual Studio 2010

Along time ago, when the Visual Studio 2010 Powershell Console was first released I started to play around with the new capabilities and I promptly forgot about it.

I recently ran across a need to have a faster way to attach to all the web processes on my computer. I remembered that I could use Powershell to access everything in Visual Studio 2010. A little digging later I ran across the "$dte" object and remembered that this was the key to accessing everything. Using "Get-Member" several times I quickly dug into
"$dte" and got a list of local processes and found an "Attach" function on the processes object.

Here is my one-line powershell command that attaches to all IIS processes and Development Web Server processes. Doing this doesn't force you to click the warning for attaching to processes that run as different users that normally appear when using the "Attach to Process..." dialog.

$dte.Debugger.LocalProcesses | ? { ($_.Name  -like "*w3wp.exe") -or ($_.Name  -like "*WebDev.WebSe*.exe") }  | % { $_.Attach(); }

I find it as a good practice to know how to undo what I do through scripting. I normally just hit the stop debug button in Visual Studio, but below is how to detach all the debugger from the processes. Perhaps someone will find it useful.

$dte.Debugger.DetachAll();

Tuesday, January 27, 2009

Where Did Debug Go?

A little while ago I loaded a project into a new install of Visual Studio 2008. I didn't think about it much at the time, but the "Solution Configuration" dropdown list (the one w/ Debug/Release compile options) was disabled on the screen. I tried to do some debugging and set my breakpoints. When the debugger attached to the process it couldn't set the breakpoints; the code wasn't compiling in debug mode.

I looked at the Modules panel in VS2008 and found that the assembly had compiled with optimization "on". Apparently the last time I compiled I my project, it was in Release mode. I look at the project properties and found the settings to be that of the Release, confirming my previous thought. I looked at the top of the build properties page and there was no dropdowns to switch to a different build configuration.

I thought perhaps something in the project file was not setup correct. So I opened the project file in notepad and looked for the build options. Everything looked like it was in the correct place and further confirmed the Release mode settings.

My next place to check was in Tools -> Options. I looked in all of the options in the tree, nothing jumped out at me. I talked with my colleagues and no one knew how to fix my issue.

I turned to my friend Google and several searches after finding nothing that seemed to fix my issue I had a glimmer of hope. The forum question:

Visual Studio 2008's Build Configuration ONLY offers DEBUG build option -- where did RELEASE GO?

That was amazingly similar to what I was experiencing but I was stuck in Release mode. Awesome, I could feel the solution to my issue was at hand. I looked to find the post marked as the answer only to find disappointment. I continued reading the posts after that and found a post by InteXX which stated:

It's in Tools\Options\Projects and Solutions. Select the Show advanced build configurations checkbox and click OK.


Sweet success! I have added a screen shot to help.



I hope this post saves people time hunting around to fix this issue. There isn't much on the web pertaining to it and the option isn't very well located.