| | |
| | | routeTemplate: "api/{controller}/{id}", |
| | | defaults: new { id = RouteParameter.Optional } |
| | | ); |
| | | |
| | | |
| | | // Web API 路由 |
| | | config.Filters.Add(new CustomHandleErrorAttribute()); |
| | | |
| | | |
| | | |
| | | //保证浏览器里面也能用 |
| | | GlobalConfiguration.Configuration.Formatters.XmlFormatter.SupportedMediaTypes.Clear(); |
| | | //默认返回 json |
| | | GlobalConfiguration.Configuration.Formatters.JsonFormatter.MediaTypeMappings.Add( |
| | | new System.Net.Http.Formatting.QueryStringMapping("datatype", "json", "application/json")); |
| | | //返回格式选择 datatype 可以替换为任何参数 |
| | | GlobalConfiguration.Configuration.Formatters.XmlFormatter.MediaTypeMappings.Add( |
| | | new System.Net.Http.Formatting.QueryStringMapping("datatype", "xml", "application/xml")); |
| | | |
| | | } |
| | | } |
| | | } |