【问题标题】:Nancy does not support periods in URLNancy 不支持 URL 中的句点
【发布时间】:2018-04-04 02:18:18
【问题描述】:

这是我在模块构造函数中定义的路径:

Get["/{company_id}/storage/{fileName}"] = x => { return ReadFileFromStorage(x.company_id, x.fileName); };

这是传入的网址:

http://localhost/MOCK/storage/foo.xml

x.fileName 设置为“foo”且仅设置为“foo”。没有显示“.xml”。 我看到以下结果:

this.Request.Path = "/MOCK/storage/foo"
this.Request.Url = "http://localhost/MOCK/storage/foo"

转义也会产生上述结果:http://localhost/MOCK/storage/foo%2Exml

请注意,在添加管道中数据很好,.xml 显示正常。

【问题讨论】:

  • 请不要在问题本身中回答您的问题。相反,使用解决方法发布实际答案。另外,不支持 URL 中的点?我会放弃那个图书馆
  • fileName.Contains("") 将始终返回 true,所以我看不到条件的意义。
  • 好的,我删除了解决方法,因为这不是我想要的。
  • 您的代码是否对所有扩展都显示此问题,或者只是 .xml

标签: c# nancy


【解决方案1】:

根据@Amy,是的,确实,这是设计使然,是内容协商的一部分,此处对 .json 扩展名的回答是:NancyFx Queries to JSON files stripping the JSON extension from request URL

【讨论】:

    猜你喜欢
    • 2012-03-05
    • 2022-08-24
    • 2015-03-31
    • 2018-04-23
    • 1970-01-01
    • 1970-01-01
    • 2013-07-07
    • 2015-05-11
    • 2013-01-17
    相关资源
    最近更新 更多