66
77namespace Simplify . Web . Modules . Redirection ;
88
9+ /// <summary>
10+ /// Provides the redirector.
11+ /// </summary>
12+ /// <seealso cref="IRedirector" />
913public class Redirector ( IWebContext context ) : IRedirector
1014{
15+ /// <summary>
16+ /// The previous page URL cookie field name
17+ /// </summary>
1118 public const string PreviousPageUrlCookieFieldName = "PreviousPageUrl" ;
1219
20+ /// <summary>
21+ /// The redirect URL cookie field name
22+ /// </summary>
1323 public const string RedirectUrlCookieFieldName = "RedirectUrl" ;
1424
25+ /// <summary>
26+ /// The login return URL cookie field name
27+ /// </summary>
1528 public const string LoginReturnUrlCookieFieldName = "LoginReturnUrl" ;
1629
30+ /// <summary>
31+ /// The previous navigated URL cookie field name
32+ /// </summary>
1733 public const string PreviousNavigatedUrlCookieFieldName = "PreviousNavigatedUrl" ;
1834
35+ /// <summary>
36+ /// Gets or sets the previous page url.
37+ /// </summary>
38+ /// <value>
39+ /// The previous page URL.
40+ /// </value>
1941 public string ? PreviousPageUrl
2042 {
2143 get => context . Request . Cookies [ PreviousPageUrlCookieFieldName ] ;
@@ -26,6 +48,12 @@ public string? PreviousPageUrl
2648 } ) ;
2749 }
2850
51+ /// <summary>
52+ /// Gets or sets the redirect url.
53+ /// </summary>
54+ /// <value>
55+ /// The redirect URL.
56+ /// </value>
2957 public string ? RedirectUrl
3058 {
3159 get => context . Request . Cookies [ RedirectUrlCookieFieldName ] ;
@@ -36,6 +64,12 @@ public string? RedirectUrl
3664 } ) ;
3765 }
3866
67+ /// <summary>
68+ /// Gets the login return URL.
69+ /// </summary>
70+ /// <value>
71+ /// The login return URL.
72+ /// </value>
3973 public string ? LoginReturnUrl
4074 {
4175 get => context . Request . Cookies [ LoginReturnUrlCookieFieldName ] ;
@@ -46,6 +80,12 @@ public string? LoginReturnUrl
4680 } ) ;
4781 }
4882
83+ /// <summary>
84+ /// Gets or sets the previous navigated URL.
85+ /// </summary>
86+ /// <value>
87+ /// The previous navigated URL.
88+ /// </value>
4989 public string ? PreviousNavigatedUrl
5090 {
5191 get => context . Request . Cookies [ PreviousNavigatedUrlCookieFieldName ] ;
@@ -56,12 +96,27 @@ public string? PreviousNavigatedUrl
5696 } ) ;
5797 }
5898
99+ /// <summary>
100+ /// Sets the redirect url to current page.
101+ /// </summary>
59102 public void SetRedirectUrlToCurrentPage ( ) => RedirectUrl = context . Request . GetEncodedUrl ( ) ;
60103
104+ /// <summary>
105+ /// Sets the login return URL from current URI.
106+ /// </summary>
61107 public void SetLoginReturnUrlFromCurrentUri ( ) => LoginReturnUrl = context . Request . GetEncodedUrl ( ) ;
62108
109+ /// <summary>
110+ /// Sets the previous page URL to current page.
111+ /// </summary>
63112 public void SetPreviousPageUrlToCurrentPage ( ) => PreviousPageUrl = context . Request . GetEncodedUrl ( ) ;
64113
114+ /// <summary>
115+ /// Navigates the client by specifying redirection type.
116+ /// </summary>
117+ /// <param name="redirectionType">Type of the redirection.</param>
118+ /// <param name="bookmarkName">Name of the bookmark.</param>
119+ /// <exception cref="ArgumentOutOfRangeException">redirectionType - null</exception>
65120 public void Redirect ( RedirectionType redirectionType , string ? bookmarkName = null )
66121 {
67122 PreviousNavigatedUrl = context . Request . GetEncodedUrl ( ) ;
@@ -97,6 +152,12 @@ public void Redirect(RedirectionType redirectionType, string? bookmarkName = nul
97152 }
98153 }
99154
155+ /// <summary>
156+ /// Redirects the client to specified URL.
157+ /// </summary>
158+ /// <param name="url">The URL.</param>
159+ /// <exception cref="ArgumentNullException">url</exception>
160+ /// <exception cref="SecurityException">Redirection outside the website, redirection URL: " + url</exception>
100161 public void Redirect ( string ? url )
101162 {
102163 if ( string . IsNullOrEmpty ( url ) )
0 commit comments