File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed
Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -57,5 +57,13 @@ public interface IWebContext : IHideObjectMembers
5757 /// <c>true</c> if current request is ajax request; otherwise, <c>false</c>.
5858 /// </value>
5959 bool IsAjax { get ; }
60+
61+ /// <summary>
62+ /// Gets the request body.
63+ /// </summary>
64+ /// <value>
65+ /// The request body.
66+ /// </value>
67+ string RequestBody { get ; }
6068 }
6169}
Original file line number Diff line number Diff line change 1- using System ;
1+ using Microsoft . AspNetCore . Http ;
2+ using System ;
3+ using System . IO ;
24using System . Threading . Tasks ;
3- using Microsoft . AspNetCore . Http ;
45
56namespace Simplify . Web . Modules
67{
@@ -10,6 +11,7 @@ namespace Simplify.Web.Modules
1011 public class WebContext : IWebContext
1112 {
1213 private readonly Lazy < IFormCollection > _form ;
14+ private readonly Lazy < string > _requestBody ;
1315
1416 /// <summary>
1517 /// Initializes a new instance of the <see cref="WebContext"/> class.
@@ -23,6 +25,7 @@ public WebContext(HttpContext context)
2325 Query = context . Request . Query ;
2426
2527 _form = new Lazy < IFormCollection > ( ( ) => Task . Run ( ( ) => context . Request . ReadFormAsync ( ) ) . Result ) ;
28+ _requestBody = new Lazy < string > ( ( ) => new StreamReader ( Context . Request . Body ) . ReadToEnd ( ) ) ;
2629
2730 VirtualPath = string . IsNullOrEmpty ( Request . PathBase . Value ) ? "" : Request . PathBase . Value ;
2831
@@ -83,5 +86,13 @@ public WebContext(HttpContext context)
8386 /// <c>true</c> if current request is ajax request; otherwise, <c>false</c>.
8487 /// </value>
8588 public bool IsAjax { get ; }
89+
90+ /// <summary>
91+ /// Gets or sets the request body.
92+ /// </summary>
93+ /// <value>
94+ /// The request body.
95+ /// </value>
96+ public string RequestBody => _requestBody . Value ;
8697 }
8798}
You can’t perform that action at this time.
0 commit comments