Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 17, 2013 08:39 AM by muhamad_ahsan
Mar 12, 2012 11:01 AM|LINK
Don't know if this is by design but....if I add a message handler to the configuration, and invoke request.GetRouteData() in its SendAsync method, I get different results depending on whether I'm running within a standard MVC 4 based web app, or a self hosted
app (using HttpSelfHostServer).
In the MVC web app, I get a non null value of GetRouteData() in the handler, but in the self hosted case, its null. If I invoke GetRouteData within my APIController though, I get a valid value even in the self host case. Does this have to do with the ordering
of the message handlers etc. or something like that? How can I fix this?
Mar 12, 2012 11:32 AM|LINK
Here's what I'm doing currently to workaround this problem....if GetRouteData returns null, I try to get it via request.GetConfiguration.Routes.GetRouteData(request).
Mar 12, 2012 10:32 PM|LINK
You guessed it right. It has to do with the order of the handlers. In the webhost case it is the asp.net infrastructure that does the routing(sits above message handlers) where as in case of selfhost it is the selfhost itself that does the routing. Can you
explain what your message handler is doing so that I can try to suggest a solution ?
Mar 13, 2012 11:16 AM|LINK
My handler is attempting to fetch some data from the route's data tokens. Like I mentioned, my current solution is to get the route data via config.Routes. Works for me currently.
Mar 13, 2012 06:51 PM|LINK
Not sure what your exact scenario is, but did you consider doing that in a filter rather than a message handler.
Mar 15, 2012 11:48 AM|LINK
I need the data much earlier in the pipeline (other handlers need this data as well), hence the decision to use a handler instead of a filter.
Jan 17, 2013 08:39 AM|LINK
I had the same issue and got the working solution as you suggested. Thanks!