【发布时间】:2015-09-08 08:19:07
【问题描述】:
我试图在我的浏览器中访问 /elmah.axd,但它返回:
{"message":"No HTTP resource was found that matches the request URI 'http://services.domain.com/elmah.axd'."}
服务器是本地的 (127.0.0.1),甚至我有我的 web.config Elmah 设置来保护它:
<elmah>
<security allowRemoteAccess="true" />
</elmah>
我的 WebApiConfig 看起来像:
public static void Register(HttpConfiguration config)
{
// Web API configuration and services
// Locally only you will be able to see the exception errors
config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.LocalOnly;
// Web API routes
config.Routes.IgnoreRoute("elmah", "elmah.axd");
config.Routes.IgnoreRoute("allemah", "elmah.axd/{*pathInfo}");
config.Routes.IgnoreRoute("elmahgeneric", "{resource}.axd/{*everything}");
config.MapHttpAttributeRoutes();
var jsonFormatter = config.Formatters.OfType<JsonMediaTypeFormatter>().First();
jsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
// Remove the XML formatter
config.Formatters.Remove(config.Formatters.XmlFormatter);
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
我什至尝试从 3 种组合中的任何一种中一次只忽略一条路线,但没有运气。
最后我的 global.asax 看起来像这样:
protected void Application_Start()
{
GlobalConfiguration.Configure(WebApiConfig.Register);
}
任何关于我可能遗漏的提示或想法都会很好。
在此先感谢,非常感谢您花时间研究此问题。
【问题讨论】:
标签: asp.net-web-api asp.net-web-api2 elmah asp.net-web-api-routing