Tutorial :Server.TransferRequest returns blank page on specific server



Question:

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!


Solution:1

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.


Solution:2

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;  }  


Solution:3

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

http://www.castleproject.org/monorail/documentation/trunk/advanced/routing.html
http://www.kenegozi.com/blog/2009/02/10/monorail-routing-and-the-homepage-routing-rule.aspx

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:
http://msmvps.com/blogs/luisabreu/archive/2007/10/09/are-you-using-the-new-transferrequest.aspx
http://support.microsoft.com/kb/817036

One suggestion is to try Request.Redirect instead.


Solution:4

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.

http://mvolo.com/blogs/serverside/archive/2007/12/08/IIS-7.0-Breaking-Changes-ASP.NET-2.0-applications-Integrated-mode.aspx

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
Previous
Next Post »