I'm handling errors in ASP.NET MVC by sending an error id from Application.OnError to a controller action, by adding a route data value that gives the error id:
Global.asax.cs/OnError:
var routeData = new RouteData(); routeData.DataTokens.Add("errorKey", errorId); var context = new RequestContext(new HttpContextWrapper(Context), routeData); errorController.Execute(context);
And then reading it in the controller/action:
object errorKey = RouteData.DataTokens["errorKey"];
On my local machine it runs fine, but on the servers I have tried the errorKey is not passed along.
What could be possible reasons for this?
A new observation, when the site is running a web server:
- If I visit from a browser on the web server itself, the route data is transferred alright
- If I visit from another machine, the route data is not transferred