C# 在REST服务中添加Atom链接
我正在使用.NET4.0和MVC4创建一个REST服务,我想为方法响应中的其他资源提供atom链接 所以答案应该是这样的:C# 在REST服务中添加Atom链接,c#,rest,atom-feed,C#,Rest,Atom Feed,我正在使用.NET4.0和MVC4创建一个REST服务,我想为方法响应中的其他资源提供atom链接 所以答案应该是这样的: <Customers xmlns:atom="http://www.w3.org/2005/Atom"> <atom:link rel="self" href="/customers"/> <Customer> <atom:link rel="self" href="/customers/101"/>
<Customers xmlns:atom="http://www.w3.org/2005/Atom">
<atom:link rel="self" href="/customers"/>
<Customer>
<atom:link rel="self" href="/customers/101"/>
<Id>101</Id>
</Customer>
</Customers>
101
我想知道如何添加atom链接
谢谢您需要进行内容协商: Web API内置了对内容协商的支持,这使客户端和服务器能够共同确定从API返回的数据的正确格式。我们提供对JSON、XML和表单URL编码格式的默认支持,您可以通过添加自己的格式化程序来扩展这种支持,甚至可以使用自己的格式化程序替换默认内容协商策略 下面是如何添加JSON格式化程序。你必须加上一个原子。链接需要位于模型的某个位置。