Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/rest/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 向响应添加HATEOAS链接_C#_Rest_Asp.net Web Api_Hateoas - Fatal编程技术网

C# 向响应添加HATEOAS链接

C# 向响应添加HATEOAS链接,c#,rest,asp.net-web-api,hateoas,C#,Rest,Asp.net Web Api,Hateoas,我正在努力在回复中加入hateoas链接。 具体来说,对于kitIncludes字段。我想有一个链接到每个记录。 例如,产品/组件 我在哪里有这个链接?这会是一个领域中的领域吗?还是应该在淘汰字段下的链接中 { "links": [ { "rel": "self", "href": "http://localhost:60778/v2/products?page=0&limit=100" }, { "rel": "f

我正在努力在回复中加入hateoas链接。 具体来说,对于kitIncludes字段。我想有一个链接到每个记录。 例如,产品/组件

我在哪里有这个链接?这会是一个领域中的领域吗?还是应该在淘汰字段下的链接中

{
"links": [
    {
        "rel": "self",
        "href": "http://localhost:60778/v2/products?page=0&limit=100"
    },
    {
        "rel": "first",
        "href": "http://localhost:60778/v2/products?page=0&limit=100"
    },
    {
        "rel": "last",
        "href": "http://localhost:60778/v2/products?page=0&limit=100"
    }
],
"metadata": {
    "totalRecords": 1
},
"entities": [
    {
        "additionalDimensions": null,
        "assemblyInstructionsUrl": null,           
        "detailedDescription": null,
        "dimensionSketch": null,
        "kitIncludes": [
            {
                "sku": "jason-component",
                "quantity": 12
            }
        ],
        "fobBasePrice": 0,
        "friendlyDescription": null,  
        "itemsPerCase": 1,
        "itemType": "Kit",
        "itemWeightKg": 0,
        "itemWeightLbs": 0,
        "knockout": null,            
        "links": [
            {
                "rel": "self",
                "href": "/products/JASON-KIT"
            },
            {
                "rel": "series",
                "href": "/series/"
            }
        ],
        "manufacturerWarrantyDays": 0,
        "mechanismGuideUrl": null,           
        "partsDrawingUrl": null,
        "productDetails": null,
        "productVideo": null,    
        "upc": null,
        "vendorName": "Test"
    }
]
}

我在哪里有这个链接

你可能想看看

从长远来看,将公共媒体类型用于您的表示,而不是尝试使用您自己的媒体类型,这可能会减少工作量

在大多数情况下,它们都有一个共同的想法:如果您在表示中找到了某个元素,并且希望查看它是否有任何链接,那么查找的路径始终位于相对于元素本身的相同位置

这意味着您应该期望每个条目都有一个链接集合

这应该是有意义的:你会如何使用网页?你会在一个地方有一堆关于kitIncludes的描述,然后在文档的其他地方有一堆超链接吗?您更有可能将链接嵌入到项目本身的描述中