@@ -26,6 +26,21 @@ public static async Task WriteJsonAsync(
2626 this HttpResponse response ,
2727 HttpStatusCode statusCode ,
2828 object value )
29+ {
30+ await WriteJsonAsync ( response , ( int ) statusCode , value , null ) ;
31+ }
32+
33+ /// <summary>
34+ /// Writes an object value as JSON to the specified <paramref name="response" />.
35+ /// </summary>
36+ /// <param name="response">The HTTP response to write to.</param>
37+ /// <param name="statusCode">The status code of the response.</param>
38+ /// <param name="value">The object to serialize as JSON.</param>
39+ /// <returns>An asynchronous operation.</returns>
40+ public static async Task WriteJsonAsync (
41+ this HttpResponse response ,
42+ int statusCode ,
43+ object value )
2944 {
3045 await WriteJsonAsync ( response , statusCode , value , null ) ;
3146 }
@@ -43,9 +58,26 @@ public static async Task WriteJsonAsync(
4358 HttpStatusCode statusCode ,
4459 object value ,
4560 JsonSerializerSettings serializerSettings )
61+ {
62+ await WriteJsonAsync ( response , ( int ) statusCode , value , serializerSettings ) ;
63+ }
64+
65+ /// <summary>
66+ /// Writes an object value as JSON to the specified <paramref name="response" />.
67+ /// </summary>
68+ /// <param name="response">The HTTP response to write to.</param>
69+ /// <param name="statusCode">The status code of the response.</param>
70+ /// <param name="value">The object to serialize as JSON.</param>
71+ /// <param name="serializerSettings">The JSON serializer settings.</param>
72+ /// <returns>An asynchronous operation.</returns>
73+ public static async Task WriteJsonAsync (
74+ this HttpResponse response ,
75+ int statusCode ,
76+ object value ,
77+ JsonSerializerSettings serializerSettings )
4678 {
4779 response . ContentType = new MediaTypeHeaderValue ( "application/json" ) { Encoding = Encoding . UTF8 } . ToString ( ) ;
48- response . StatusCode = ( int ) statusCode ;
80+ response . StatusCode = statusCode ;
4981
5082 string json = JsonConvert . SerializeObject ( value , Formatting . Indented , serializerSettings ) ;
5183
0 commit comments