【问题标题】:UriTemplate with period returns 404 in MVC Application带有句点的 UriTemplate 在 MVC 应用程序中返回 404
【发布时间】:2012-05-18 03:09:58
【问题描述】:

我在 MVC3 Web 应用程序中托管 WCF 服务。我有一个带有 UriTemplate 的 WebGet 属性的方法设置。当 UriTemplate 包含句点时,我会从 Web 服务器收到 404 响应。

    [OperationContract, WebGet(UriTemplate = "DoSomething")]
    Stream DoWork();

http://localhost/Services/Service1.svc/DoSomething  - Works Correctly

    [OperationContract, WebGet(UriTemplate = "dummyfile.xml")]
    Stream DoWork();

http://localhost/Services/Service1.svc/dummyfile.xml - Returns a 404 error

我猜这与路线有关,但我不确定。我现在设置的路线是:

    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    routes.IgnoreRoute("{resource}.svc/{*pathInfo}");

    routes.MapRoute( "Default", "{controller}/{action}/{id}",  new { controller = "Home", action = "Index", id = UrlParameter.Optional });

谁能提供一些关于如何使用带有句点的 URITemplate 在 MVC3 应用程序中托管 WCF 服务的见解?

【问题讨论】:

  • 菲尔哈克有the answer
  • @EdSF 为什么不添加该评论作为答案,以便他同意您的意见:)

标签: c# asp.net wcf asp.net-mvc-3


【解决方案1】:

冒着抄袭的风险 :) Phil Haack has the answer

【讨论】:

  • 谢谢。这绝对是问题的一部分。 ASP.Net 开发服务器也不喜欢 URL 中有句点。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-11-24
  • 1970-01-01
  • 2021-04-06
  • 1970-01-01
  • 2014-07-16
  • 2011-07-03
相关资源
最近更新 更多