@@ -9,6 +9,7 @@ namespace Simplify.Web.Modules.Context;
99/// <summary>
1010/// Provides the web context.
1111/// </summary>
12+ /// <seealso cref="IWebContext" />
1213public sealed class WebContext : IWebContext
1314{
1415 private readonly SemaphoreSlim _formReadSemaphore = new ( 1 , 1 ) ;
@@ -18,7 +19,7 @@ public sealed class WebContext : IWebContext
1819 private string ? _requestBody ;
1920
2021 /// <summary>
21- /// Initializes a new instance of the <see cref="WebContext"/> class.
22+ /// Initializes a new instance of the <see cref="WebContext" /> class.
2223 /// </summary>
2324 /// <param name="context">The HTTP context.</param>
2425 public WebContext ( HttpContext context )
@@ -37,20 +38,69 @@ public WebContext(HttpContext context)
3738 Route = Request . Path . Value ?? "/" ;
3839 }
3940
41+ /// <summary>
42+ /// Gets the current web-site route, for example: "/" or "/user/delete/15"/
43+ /// </summary>
44+ /// <value>
45+ /// The route.
46+ /// </value>
4047 public string Route { get ; }
4148
49+ /// <summary>
50+ /// Gets the site root url, for example: http://mysite.com or http://localhost/mysite//
51+ /// </summary>
52+ /// <value>
53+ /// The site URL.
54+ /// </value>
4255 public string SiteUrl { get ; }
4356
57+ /// <summary>
58+ /// Gets the virtual path.
59+ /// </summary>
60+ /// <value>
61+ /// The virtual path.
62+ /// </value>
4463 public string VirtualPath { get ; }
4564
65+ /// <summary>
66+ /// Gets the context for the current HTTP request.
67+ /// </summary>
68+ /// <value>
69+ /// The context.
70+ /// </value>
4671 public HttpContext Context { get ; }
4772
73+ /// <summary>
74+ /// Gets the request for the current HTTP request.
75+ /// </summary>
76+ /// <value>
77+ /// The request.
78+ /// </value>
4879 public HttpRequest Request { get ; }
4980
81+ /// <summary>
82+ /// Gets the response for the current HTTP request.
83+ /// </summary>
84+ /// <value>
85+ /// The response.
86+ /// </value>
5087 public HttpResponse Response { get ; }
5188
89+ /// <summary>
90+ /// Gets the query string for current HTTP request.
91+ /// </summary>
92+ /// <value>
93+ /// The query.
94+ /// </value>
5295 public IQueryCollection Query { get ; }
5396
97+ /// <summary>
98+ /// Gets the form data of post HTTP request.
99+ /// </summary>
100+ /// <value>
101+ /// The form.
102+ /// </value>
103+ /// <exception cref="InvalidOperationException">Form is null</exception>
54104 public IFormCollection Form
55105 {
56106 get
@@ -67,10 +117,28 @@ public IFormCollection Form
67117 }
68118 }
69119
120+ /// <summary>
121+ /// Gets a value indicating whether this request is ajax request.
122+ /// </summary>
123+ /// <value>
124+ /// <c>true</c> if current request is ajax request; otherwise, <c>false</c>.
125+ /// </value>
70126 public bool IsAjax { get ; }
71127
128+ /// <summary>
129+ /// Gets a value indicating whether current request context user is not null and is authenticated.
130+ /// </summary>
131+ /// <value>
132+ /// <c>true</c> if this instance is authenticated; otherwise, <c>false</c>.
133+ /// </value>
72134 public bool IsAuthenticated => Context . User is { Identity . IsAuthenticated : true } ;
73135
136+ /// <summary>
137+ /// Gets the request body.
138+ /// </summary>
139+ /// <value>
140+ /// The request body.
141+ /// </value>
74142 public string RequestBody
75143 {
76144 get
@@ -84,6 +152,9 @@ public string RequestBody
84152 }
85153 }
86154
155+ /// <summary>
156+ /// Reads the form asynchronously.
157+ /// </summary>
87158 public async Task ReadFormAsync ( )
88159 {
89160 if ( _form != null )
@@ -101,6 +172,9 @@ public async Task ReadFormAsync()
101172 }
102173 }
103174
175+ /// <summary>
176+ /// Reads the request body asynchronously.
177+ /// </summary>
104178 public async Task ReadRequestBodyAsync ( )
105179 {
106180 if ( _requestBody != null )
0 commit comments