Giter Site home page Giter Site logo

threeway's Introduction

ThreeWay

A demonstration of how to serve HTML, JSON and XML from a single ASP.NET MVC endpoint.

It is not uncommon to see multiple endpoints in a project that exist solely to serve different formats of the same data.

This project shows one way to serve three different result formats based on header values from the caller. Specifically, if the client requests application/json or application/xml content, then JSON or XML is returned by the server.

NB This code, in particular the XML approach, is not recommended for any but the simplest of use cases. XML is rigid/fragile and verbose. When a client needs it, there are often other requirements that suggest WCF or another solution.

NB Circular dependencies can be a problem. For example, if you have a Person object that includes a collection of other related Person objects, and if one or more of those objects has a reference to the first Person object, then problems can arise from this naïve approach.

Caveat lector

threeway's People

Contributors

stand-sure avatar

Watchers

James Cloos avatar  avatar

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.