File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 33namespace Asp . Versioning ;
44
55using Asp . Versioning . Routing ;
6+ #if NETFRAMEWORK
7+ using System . Net ;
8+ #endif
69using static Asp . Versioning . ApiVersionReader ;
710
811/// <summary>
@@ -100,4 +103,35 @@ public IApiVersioningPolicyBuilder Policies
100103 get => apiVersioningPolicyBuilder ??= new ApiVersioningPolicyBuilder ( ) ;
101104 set => apiVersioningPolicyBuilder = value ;
102105 }
106+
107+ /// <summary>
108+ /// Gets or sets the HTTP status code used for unsupported versions of an API.
109+ /// </summary>
110+ /// <value>The HTTP status code. The default value is 400 (Bad Request).</value>
111+ /// <remarks>
112+ /// <para>While any HTTP status code can be provided, the following are the most sensible:</para>
113+ /// <list type="table">
114+ /// <listheader>
115+ /// <term>Status</term>
116+ /// <description>Description</description>
117+ /// </listheader>
118+ /// <item>
119+ /// <term>400 (Bad Request)</term>
120+ /// <description>The API doesn't support this version</description>
121+ /// </item>
122+ /// <item>
123+ /// <term>404 (Not Found)</term>
124+ /// <description>The API doesn't exist</description>
125+ /// </item>
126+ /// <item>
127+ /// <term>501 (Not Implemented)</term>
128+ /// <description>The API isn't implemented</description>
129+ /// </item>
130+ /// </list>
131+ /// </remarks>
132+ #if NETFRAMEWORK
133+ public HttpStatusCode UnsupportedApiVersionStatusCode { get ; set ; } = HttpStatusCode . BadRequest ;
134+ #else
135+ public int UnsupportedApiVersionStatusCode { get ; set ; } = 400 ;
136+ #endif
103137}
You can’t perform that action at this time.
0 commit comments