Tutorial :Server.TransferRequest returns blank page on specific server


I'm facing an issue that seems to be related to configuration.

I have a webapplication based on MonoRail, where we utilize the routing feature from MonoRail. On the first request after the application has started, the routing isn't initialized. To circumvent this, I have the following code in Application_OnError():

public virtual void Application_OnError()  {      if ( // identified as routing error )      Server.TransferRequest( Context.Request.RawUrl, false );      return;  }  

Problem beeing that on our development server (which runs server 2008 R2, with IIS 7.5 and .NET 3.5) returns a blank page without headers, but on my workstation (which runs win7, IIS 7.5 and .NET 3.5) it works fine.

What could be the cause of this? If the code in Application_OnError() throws an exception, what would be the expected output?

I have verified the following:

  • The access-log shows one entry, I'm not sure if a TransferRequest would show up as a second entry when invoked successfully
  • The application actually do some work according to my internal logs, and it doesn't die since a subsequent requests works flawlessly (because routing will be active)

Any hints on what to look for would be greatly appreciated!


Is the application pool on the Server install configured to use the integrated pipeline? It needs to be in order for Server.TransferRequest to work.

From MSDN Documentation:

This method is used when running with the integrated pipeline mode in IIS 7.0 to allow request processing to be transferred from one resource type to another while executing the target request with the correct request context.


I think that there is a throw error, but you do not see it because your page is all ready on some other error and you need to capture it that way. After that you can find the real problem, because from my checks in TransferRequest can be many thinks that give error.

public virtual void Application_OnError()  {      if ( identified as routing error )      {          try          {                  Server.TransferRequest( Context.Request.RawUrl, false );          }          catch(Exception x)              {              LogTheError(x.ToString());          }      }        return;  }  


You may need to set up your routing during Application_OnStart() in order to get the routing registered in time for your first request.


Where do you have it registering routes right now?

Additional suggestions

Here's a couple more things to looks at around CompleteRequest and URL Rewriting:

One suggestion is to try Request.Redirect instead.


One thing you should look into is Server.ClearError(). There are some breaking changes from Win 7 and Server 2008 with the pipeline and errors.


Look at item #21 in the list.

Not sure if this is your problem but it seems like it might be something worth checking.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »