我正在用.NET开发一个WEB API,我想用swagger来记录它。我的默认路线是:
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
但是当我尝试访问localhost时,它会给我这个错误:55800 / swagger:
{
"$id": "1",
"message": "No HTTP resource was found that matches the request URI 'http://localhost:55800/swagger/ui/index'.",
"messageDetail": "No type was found that matches the controller named 'swagger'."
}
我用这个命令改变了招摇的路线:
config.EnableSwaggerUi("apihelp/{*assetPath}", c =>
... // following lines omitted
但是我仍然无法在MapHttpRoute方法中从我的routeTemplate中删除“api”前缀。
如何在MapHttpRoute上识别没有此“api”前缀的路线?