views:

53

answers:

1

(I'm also asking this on the OpenRasta google group)

Hey all,

I've been using OpenRasta to convert an old web application we have into something RESTful. IS it possible to serve up a resource (or specifically a list of resources) as both .aspx and JSON? I have tried this but no matter what I try I keep getting the .aspx back ... any ideas? Here's a sample configuration:

ResourceSpace.Has.ResourcesOfType<List<Valueset>>()
    .AtUri("/valuesets")
    .HandledBy<ValuesetHandler>()
    .AsJsonDataContract()
    .And.AsXmlDataContract()
    .And.RenderedByAspx("~/Views/VauesetView.aspx")
+1  A: 
GET /valuesets
Accept: application/json
serialseb
I first ran across this using jQuery Grid (though I smartened up and use a different resource now because it just makes sense) however should it happen again ... what if the Accept header contains this: application/json, text/javascript, */*. Does the */* cause OpenRasta to send back Aspx if both Aspx and JSON happen to be served by the same resource?? Just curious ...
Jeffrey Cameron
Yes it would, it's by design. If you say that both the html and the javascript are acceptable at the same quality level, either will be returned. Either put a ;q=whatever attribute on the client in your accept header, or do that on your server config to give higher priority to another media type.
serialseb