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?
Thanks,
Priya
Please "Mark as Answer" if this resolves your query. Thanks!
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).
Please "Mark as Answer" if this resolves your query. Thanks!
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 ?
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.
Thanks,
Priya
Please "Mark as Answer" if this resolves your query. Thanks!
priya_marwah...
Member
81 Points
52 Posts
GetRouteData() is null in Self Hosted delegating handler
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?
Thanks,
Priya
priya_marwah...
Member
81 Points
52 Posts
Re: GetRouteData() is null in Self Hosted delegating handler
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).
raghuramn
Member
248 Points
64 Posts
Microsoft
Re: GetRouteData() is null in Self Hosted delegating handler
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 ?
priya_marwah...
Member
81 Points
52 Posts
Re: GetRouteData() is null in Self Hosted delegating handler
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.
Thanks,
Priya
raghuramn
Member
248 Points
64 Posts
Microsoft
Re: GetRouteData() is null in Self Hosted delegating handler
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.
priya_marwah...
Member
81 Points
52 Posts
Re: GetRouteData() is null in Self Hosted delegating 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.
Thanks,
Priya
muhamad_ahsa...
Member
3 Points
12 Posts
Re: GetRouteData() is null in Self Hosted delegating handler
Jan 17, 2013 08:39 AM|LINK
Hi Priya,
I had the same issue and got the working solution as you suggested. Thanks!