Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/hadoop/6.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# 为什么我的Nancyfx谈判代表没有返回正确的模型?_C#_Nancy - Fatal编程技术网

C# 为什么我的Nancyfx谈判代表没有返回正确的模型?

C# 为什么我的Nancyfx谈判代表没有返回正确的模型?,c#,nancy,C#,Nancy,我定义了以下路线: Get["/test"] = _ => Negotiate .WithModel(new { Name = "This is base model " }) .WithMediaRangeModel(new MediaRange("text/html"), new { Name = "This is text/html" }) .WithMediaRangeModel(new MediaRange("text/plain"), new { Nam

我定义了以下路线:

Get["/test"] = _ => Negotiate
    .WithModel(new { Name = "This is base model " })
    .WithMediaRangeModel(new MediaRange("text/html"), new { Name = "This is text/html" })
    .WithMediaRangeModel(new MediaRange("text/plain"), new { Name = "This is text/plain" })
    .WithView("index");
我得到的是:

Accepts header            Actual response (content-type + model)
-----------------         -----------------------------------------
text/html            (OK) HTML view with "html" model 
application/json     (OK) application/json with "base" model
text/plain                HTTP 406 
text/*                    application/json with "html" model 
*/*                       application/json with "html" model 
因此:

  • 如何让
    “text/plain”
    模型返回
    接受:text/plain
  • 为什么要为
    */*
    返回“html”模型(内容类型为
    application/json
我真的只需要一个JSON模型(或任何其他格式),在呈现HTML视图时使用不同的模型(包括PageTitle和其他一些特定于HTML的内容)

这对我来说很像一个bug,但由于我是NancyFx的新手,而且它已经存在了一段时间,我会认为我做错了什么

我正在使用Nancy 1.4.3和Nancy.Hosting.Self 1.4.1