Alex Olivier

Tech, Media, Musicals

Quick Tip: URL Rewrite Conditions

If you get an error about no route found when using ARR/URL Rewrite, it can be because you have no condition setup on your rule.

My original thinking, is that if you don’t have any conditions, it would just route every request that matches the incoming URL, this doesn’t seem to be the case.

Make sure you have at least one rule {HTTP_HOST} or something that will be the catch for the requests coming in.

image

Event Tracing in HTTP.sys

I have been working on an issue where by requests are being sent from one server, but the connection appears to be reset.

One method of troubleshooting this is to enable something called Event Tracing for Windows, specifically tracing the events from the HTTP.sys system. HTTP.sys is the kernel level side of a web request. All requests that go to IIS pass through this, so it will trap any events.

To start tracing events in Http.sys use the logman.exe tool. Logman.exe ships with every Windows installation, and can be used right out of the box. To enable ETW, type:

C:> logman start httptrace -p Microsoft-Windows-HttpService 0xFFFF -o tracefile.etl -ets

Here tracefile is the name of our trace. This will be used to identify this particular event trace in further commands. Logman needs to know which components of Windows to trace. Since we are only interested in tracing Http.sys, we pass the provider name, "Microsoft-Windows-HttpService". The 0xFFFF signifies we want full tracing, or all trace events. Our event trace will be written to a raw binary file, tracefile.etl. Please note that you must be an elevated Admin to use the logman command.

To stop tracing we use the logman tool again:

C:> logman stop httptrace –ets

You can now open up this ETL file up in Event Viewer, which give you a very nice verbose view of the request passing through.

image

Now you will be able to see if a request is passing through your system or not!

Feel free to email me alex[at]olivierdigital[dot]com if you need any help!

Alex

Getting Started with windbg

WinDbg for those that don’t know (and I suspect most as I didn’t know till about 3 months ago) is THE tool for debugging Windows. The guys I work with live in it (looking at you @dougste) and it really is extremely powerful. Its clever enough to go down to the line inside your code that is causing your whole app to crash, without having any previous knowledge of your program. Just get a memory dump and it will go.

I have been struggling to get to grips with this stuff, heaps, stacks, clrs, gc’s, gen 0, etc, and have finally come across a very useful duo of blogs posts that cover how to get setup and start finding the bugs:

Getting started with windbg – Part I and Part 2

These are written by JohanSt over at MSDN. I can also recommend reading through my colleague Doug Stewart’s blog who is the Principal Escalation Engineer in my team, and trust me, this guy is a genius/Jedi/Matrix-dweller.

Supress Text Highlighting in Webpages

I have been working on a problem were a system was displaying a web app on a touch screen. When it came to press and dragging elements around a page, the default behaviour of highlighting text starts. This is not desirable when your trying to be an application. Thankfully supressing this in IE is just one line of JavaScript:

<script>document.body.onselectstart=function(){return false}</script>

Simple as, put that just before you </body> tag, or call it onload, and the default event is overridden and no highlighting occurs.

Case closed.