御泥坊面膜怎么样,怎么缩阴,义乌人才网最新招聘信息
集将应用于 contactsconventioncontroller 中的所有操作:
[apicontroller] [apiconventiontype(typeof(defaultapiconventions))] [route("api/[controller]")] public class contactsconventioncontroller : controllerbase {
默认的约定集将应用于程序集中的所有操作:
[assembly: apiconventiontype(typeof(defaultapiconventions))] namespace apiconventions { public class startup {
如果默认 api 约定不能满足需要,请创建自己的约定。 约定是:
这些方法使用 [producesresponsetype]
或 [producesdefaultresponsetype]
属性进行批注。 例如:
c#复制
public static class myappconventions { [producesresponsetype(statuscodes.status200ok)] [producesresponsetype(statuscodes.status404notfound)] public static void find(int id) { } }
如果没有更具体的元数据属性,则将此约定应用于程序集可强制实现以下内容:
find
的操作。id
操作上存在名为 find
的参数。[apiconventionnamematch]
和 [apiconventiontypematch]
属性可应用于约定方法,确定它们所要应用的操作。 例如:
c#复制
[producesresponsetype(statuscodes.status200ok)] [producesresponsetype(statuscodes.status404notfound)] [apiconventionnamematch(apiconventionnamematchbehavior.prefix)] public static void find( [apiconventionnamematch(apiconventionnamematchbehavior.suffix)] int id) { }
在上面的示例中:
microsoft.aspnetcore.mvc.apiexplorer.apiconventionnamematchbehavior.prefix
选项表示该约定可匹配前缀是“find”的任何操作。 匹配的操作可以是 find
、findpet
和 findbyid
。microsoft.aspnetcore.mvc.apiexplorer.apiconventionnamematchbehavior.suffix
表示该约定可匹配带有唯一以标识符作为后缀结尾的参数的方法。 示例包括 id
或 petid
等参数。 与此类似,可将 apiconventiontypematch
应用于类型,以约束参数类型。 params[]
参数指示无需显式匹配的剩余参数。
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Blazor server side 自家的一些开源的, 实用型项目的进度之 CEF客户端
.NET IoC模式依赖反转(DIP)、控制反转(Ioc)、依赖注入(DI)
vue+.netcore可支持业务代码扩展的开发框架 VOL.Vue 2.0版本发布
网友评论