带有句点的 UriTemplate 在 MVC 应用程序中返回 404

本文关键字:应用程序 返回 MVC 句点 UriTemplate | 更新日期: 2023-09-27 18:34:11

我在 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 服务?

带有句点的 UriTemplate 在 MVC 应用程序中返回 404

着抄袭的风险:)菲尔·哈克有答案