Giter Club home page Giter Club logo

Comments (2)

filipw avatar filipw commented on August 17, 2024

yes, the SO example doesn't set the content type header correctly. Set it
to application/json or use different method of creating JSON response (i.e.
JsonResult : IHttpActionResult)

On 15 December 2013 00:25, snblackout [email protected] wrote:

Using V2 line 153 of CacheOutputAttribute.cs:

_webApiCache.Add(cachekey + Constants.ContentTypeKey,
actionExecutedContext.Response.Content.Headers.ContentType.MediaType,
cacheTime.AbsoluteExpiration, baseKey);

Headers.ContentType = null.

I'm decorating my GET function like:

Public Function DoGetThis(ByVal guid As String) As HttpResponseMessage

Returning:
New HttpResponseMessage() With {.Content = New JsonContent(New With {Key
.Success = True, Key .Message = "Success", .NowPlaying = data})}

data is my own business logic class.
JsonContent is from
http://stackoverflow.com/questions/14231877/how-to-return-json-object-on-web-api-controller

Am I doing something wrong?


Reply to this email directly or view it on GitHubhttps://github.com//issues/51
.

from strathweb.cacheoutput.

snblackout avatar snblackout commented on August 17, 2024

Thank you, I just decided to ditch the JsonContent from the SO article and just did:

Return Request.CreateResponse(Of MyClass)(HttpStatusCode.OK, New MyClass())

That way your OutputCache is working fine and I can still return my own class structure back over the line.

from strathweb.cacheoutput.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.