Exemplo n.º 1
0
 /// <summary>
 /// Adds a rule to the current rules.
 /// </summary>
 /// <param name="options">The <see cref="RewriteOptions"/>.</param>
 /// <param name="rule">A rule to be added to the current rules.</param>
 /// <returns>The Rewrite options.</returns>
 public static RewriteOptions Add(this RewriteOptions options, IRule rule)
 {
     options.Rules.Add(rule);
     return(options);
 }
Exemplo n.º 2
0
 /// <summary>
 /// Redirect the request to the www subdomain if the incoming request is non-www.
 /// </summary>
 /// <param name="options">The <see cref="RewriteOptions"/>.</param>
 /// <param name="statusCode">The status code to add to the response.</param>
 public static RewriteOptions AddRedirectToWww(this RewriteOptions options, int statusCode)
 {
     options.Rules.Add(new RedirectToWwwRule(statusCode));
     return(options);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Redirect the request to the www subdomain if the incoming request is non-www.
 /// </summary>
 /// <param name="options">The <see cref="RewriteOptions"/>.</param>
 /// <param name="statusCode">The status code to add to the response.</param>
 /// <param name="domains">Limit the rule to apply only on the specified domain(s).</param>
 public static RewriteOptions AddRedirectToWww(this RewriteOptions options, int statusCode, params string[] domains)
 {
     options.Rules.Add(new RedirectToWwwRule(statusCode, domains));
     return(options);
 }
Exemplo n.º 4
0
        public static RewriteOptions AddRedirectToLowercase(this RewriteOptions options, int statuscode)
        {
            options.Add(new RedirectToLowercaseRule(statuscode));

            return(options);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Redirect the request to the www subdomain if the incoming request is non-www.
 /// </summary>
 /// <param name="options">The <see cref="RewriteOptions"/>.</param>
 /// <param name="domains">Limit the rule to apply only on the specified domain(s).</param>
 public static RewriteOptions AddRedirectToWww(this RewriteOptions options, params string[] domains)
 {
     return(AddRedirectToWww(options, statusCode: StatusCodes.Status307TemporaryRedirect, domains));
 }
Exemplo n.º 6
0
 /// <summary>
 /// Redirect the request if the regex matches the HttpContext's PathString
 /// </summary>
 /// <param name="options">The <see cref="RewriteOptions"/>.</param>
 /// <param name="regex">The regex string to compare with.</param>
 /// <param name="replacement">If the regex matches, what to replace the uri with.</param>
 /// <returns>The Rewrite options.</returns>
 public static RewriteOptions AddRedirect(this RewriteOptions options, string regex, string replacement)
 {
     return(AddRedirect(options, regex, replacement, statusCode: StatusCodes.Status302Found));
 }
Exemplo n.º 7
0
 /// <summary>
 /// Redirect a request to https if the incoming request is http, with returning a 301
 /// status code for permanently redirected.
 /// </summary>
 /// <param name="options">The <see cref="RewriteOptions"/>.</param>
 /// <returns></returns>
 public static RewriteOptions AddRedirectToHttpsPermanent(this RewriteOptions options)
 {
     return(AddRedirectToHttps(options, statusCode: StatusCodes.Status301MovedPermanently, sslPort: null));
 }
Exemplo n.º 8
0
        public static RewriteOptions ForceToAppendTrailingSlash(this RewriteOptions options, int statusCode)
        {
            options.AddRedirect("(.*[^/])$", "$1/", statusCode);

            return(options);
        }
Exemplo n.º 9
0
 /// <summary>
 /// Redirect a request to https if the incoming request is http
 /// </summary>
 /// <param name="options">The <see cref="RewriteOptions"/>.</param>
 /// <param name="statusCode">The status code to add to the response.</param>
 public static RewriteOptions AddRedirectToHttps(this RewriteOptions options, int statusCode)
 {
     return(AddRedirectToHttps(options, statusCode, sslPort: null));
 }
Exemplo n.º 10
0
        public static RewriteOptions AddRedirectToNonWww(this RewriteOptions options)
        {
            options.AddRedirectToNonWww(307);

            return(options);
        }
Exemplo n.º 11
0
        public static RewriteOptions ForceToAppendTrailingSlashPermanent(this RewriteOptions options)
        {
            options.ForceToAppendTrailingSlash(308);

            return(options);
        }
Exemplo n.º 12
0
        public static RewriteOptions ForceToStripTrailingSlash(this RewriteOptions options, int statusCode)
        {
            options.AddRedirect("(.*)/$", "$1", statusCode);

            return(options);
        }
Exemplo n.º 13
0
        public static RewriteOptions ForceToStripTrailingSlash(this RewriteOptions options)
        {
            options.ForceToStripTrailingSlash(307);

            return(options);
        }
Exemplo n.º 14
0
        public static RewriteOptions AddCanonicalUrl(this RewriteOptions options, int statuscode, bool forceLowercaseUrls, TrailingSlashAction trailingSlash)
        {
            options.Add(new RedirectToCanonicalUrlRule(statuscode, forceLowercaseUrls, trailingSlash));

            return(options);
        }
Exemplo n.º 15
0
 /// <summary>
 /// Adds a rule to the current rules.
 /// </summary>
 /// <param name="options">The <see cref="RewriteOptions"/>.</param>
 /// <param name="applyRule">A Func that checks and applies the rule.</param>
 /// <returns></returns>
 public static RewriteOptions Add(this RewriteOptions options, Action <RewriteContext> applyRule)
 {
     options.Rules.Add(new DelegateRule(applyRule));
     return(options);
 }
Exemplo n.º 16
0
 /// <summary>
 /// Permanently redirects the request to the www subdomain if the request is non-www.
 /// </summary>
 /// <param name="options">The <see cref="RewriteOptions"/>.</param>
 /// <returns></returns>
 public static RewriteOptions AddRedirectToWwwPermanent(this RewriteOptions options)
 {
     return(AddRedirectToWww(options, statusCode: StatusCodes.Status308PermanentRedirect));
 }
Exemplo n.º 17
0
 /// <summary>
 /// Adds a rule that rewrites the path if the regex matches the HttpContext's PathString.
 /// </summary>
 /// <param name="options">The <see cref="RewriteOptions"/>.</param>
 /// <param name="regex">The regex string to compare with.</param>
 /// <param name="replacement">If the regex matches, what to replace the uri with.</param>
 /// <param name="skipRemainingRules">If the regex matches, conditionally stop processing other rules.</param>
 /// <returns>The Rewrite options.</returns>
 public static RewriteOptions AddRewrite(this RewriteOptions options, string regex, string replacement, bool skipRemainingRules)
 {
     options.Rules.Add(new RewriteRule(regex, replacement, skipRemainingRules));
     return(options);
 }
Exemplo n.º 18
0
 /// <summary>
 /// Permanently redirects the request to the www subdomain if the request is non-www.
 /// </summary>
 /// <param name="options">The <see cref="RewriteOptions"/>.</param>
 /// <param name="domains">Limit the rule to apply only on the specified domain(s).</param>
 /// <returns></returns>
 public static RewriteOptions AddRedirectToWwwPermanent(this RewriteOptions options, params string[] domains)
 {
     return(AddRedirectToWww(options, statusCode: StatusCodes.Status308PermanentRedirect, domains));
 }
Exemplo n.º 19
0
 /// <summary>
 /// Redirect the request if the regex matches the HttpContext's PathString
 /// </summary>
 /// <param name="options">The <see cref="RewriteOptions"/>.</param>
 /// <param name="regex">The regex string to compare with.</param>
 /// <param name="replacement">If the regex matches, what to replace the uri with.</param>
 /// <param name="statusCode">The status code to add to the response.</param>
 /// <returns>The Rewrite options.</returns>
 public static RewriteOptions AddRedirect(this RewriteOptions options, string regex, string replacement, int statusCode)
 {
     options.Rules.Add(new RedirectRule(regex, replacement, statusCode));
     return(options);
 }
Exemplo n.º 20
0
 /// <summary>
 /// Redirect the request to the www subdomain if the incoming request is non-www.
 /// </summary>
 /// <param name="options">The <see cref="RewriteOptions"/>.</param>
 public static RewriteOptions AddRedirectToWww(this RewriteOptions options)
 {
     return(AddRedirectToWww(options, statusCode: StatusCodes.Status307TemporaryRedirect));
 }
Exemplo n.º 21
0
 /// <summary>
 /// Redirect a request to https if the incoming request is http
 /// </summary>
 /// <param name="options">The <see cref="RewriteOptions"/>.</param>
 public static RewriteOptions AddRedirectToHttps(this RewriteOptions options)
 {
     return(AddRedirectToHttps(options, statusCode: StatusCodes.Status302Found, sslPort: null));
 }
Exemplo n.º 22
0
        public static RewriteOptions AddRedirectToLowercasePermanent(this RewriteOptions options)
        {
            options.AddRedirectToLowercase(308);

            return(options);
        }