Corrupt output with an HttpModule

Posted by clementi on Stack Overflow See other posts from Stack Overflow or by clementi
Published on 2012-09-27T21:35:37Z Indexed on 2012/09/27 21:37 UTC
Read the original article Hit count: 155

Filed under:
|
|
|
|

I have an HttpModule that looks at the query string for a parameter called "cmd" and executes one of a small set of predefined commands that display server stats in XML. For example, http://server01?cmd=globalstats. Now, on rare occasions, like once out of hundreds of times, I will get corrupt output like this:

<!-- the stats start displaying fine... -->
<stats>
  <ServerName>SERVER01</ServerName>
  <StackName>Search</StackName>
  <TotalRequests>945</TotalRequests>
<!-- ...until something has gone awry and now we're getting the markup of the home page! -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
...the rest of the home page markup...

(Remove the comments in the example above.)

I'm not all that familiar with HttpModules and the IIS pipeline, but could this be a threading problem? Or, what else?

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET