I have an application that is going to act as a "catch-all" for requests that could be coming from a variety of targets. I would like to be able to redirect to a different controller/action in my application based on the value of the "accept" header.
Clarification: I would like to do this without an HTTP Handler, if possible.
make a route.. just a simple class and derive it from
RouteBase
here you will find the methodGetRouteData(System.Web.HttpContextBase httpContext)
with return type ofRouteData
u can pick out the headers of your choice from thehttpcontext
and add the values of ur route to the return value of the function..you can use Phil haack Route Magic plugin it has HttpHandler Routing but it use HttpHandler you can take a look , see if you like it
Route Magic
You could write a custom route:
and then register this route:
Now when you POST to
/home
and set theAccept
request header toxml
theXml
action of theHome
controller will be hit.