{
namespace Microsoft.AspNetCore.Rewrite {
public static class IISUrlRewriteOptionsExtensions {
- public static RewriteOptions AddIISUrlRewrite(this RewriteOptions options, IFileProvider fileProvider, string filePath);
+ public static RewriteOptions AddIISUrlRewrite(this RewriteOptions options, IFileProvider fileProvider, string filePath, bool alwaysUseManagedServerVariables = false);
- public static RewriteOptions AddIISUrlRewrite(this RewriteOptions options, TextReader reader);
+ public static RewriteOptions AddIISUrlRewrite(this RewriteOptions options, TextReader reader, bool alwaysUseManagedServerVariables = false);
}
public class RewriteMiddleware {
- public RewriteMiddleware(RequestDelegate next, IHostingEnvironment hostingEnvironment, ILoggerFactory loggerFactory, IOptions<RewriteOptions> options);
+ public RewriteMiddleware(RequestDelegate next, IWebHostEnvironment hostingEnvironment, ILoggerFactory loggerFactory, IOptions<RewriteOptions> options);
}
public static class RewriteOptionsExtensions {
+ public static RewriteOptions AddRedirectToWww(this RewriteOptions options, int statusCode, params string[] domains);
+ public static RewriteOptions AddRedirectToWww(this RewriteOptions options, params string[] domains);
+ public static RewriteOptions AddRedirectToWwwPermanent(this RewriteOptions options, params string[] domains);
}
}
- namespace Microsoft.AspNetCore.Rewrite.Internal {
{
- public class BackReferenceCollection {
{
- public BackReferenceCollection(string reference);
- public BackReferenceCollection(GroupCollection references);
- public string this[int index] { get; }
- public void Add(BackReferenceCollection references);
- }
- public class DelegateRule : IRule {
{
- public DelegateRule(Action<RewriteContext> onApplyRule);
- public void ApplyRule(RewriteContext context);
- }
- public class MatchResults {
{
- public static readonly MatchResults EmptyFailure;
- public static readonly MatchResults EmptySuccess;
- public MatchResults();
- public BackReferenceCollection BackReferences { get; set; }
- public bool Success { get; set; }
- }
- public class ParserContext {
{
- public readonly string Template;
- public ParserContext(string condition);
- public char Current { get; }
- public int Index { get; set; }
- public bool Back();
- public string Capture();
- public int GetIndex();
- public bool HasNext();
- public void Mark();
- public bool Next();
- }
- public class Pattern {
{
- public Pattern(IList<PatternSegment> patternSegments);
- public IList<PatternSegment> PatternSegments { get; }
- public string Evaluate(RewriteContext context, BackReferenceCollection ruleBackReferences, BackReferenceCollection conditionBackReferences);
- }
- public abstract class PatternSegment {
{
- protected PatternSegment();
- public abstract string Evaluate(RewriteContext context, BackReferenceCollection ruleBackReferences, BackReferenceCollection conditionBackReferences);
- }
- public class RedirectRule : IRule {
{
- public RedirectRule(string regex, string replacement, int statusCode);
- public Regex InitialMatch { get; }
- public string Replacement { get; }
- public int StatusCode { get; }
- public virtual void ApplyRule(RewriteContext context);
- }
- public class RedirectToHttpsRule : IRule {
{
- public RedirectToHttpsRule();
- public int? SSLPort { get; set; }
- public int StatusCode { get; set; }
- public virtual void ApplyRule(RewriteContext context);
- }
- public class RedirectToWwwRule : IRule {
{
- public readonly int _statusCode;
- public RedirectToWwwRule(int statusCode);
- public virtual void ApplyRule(RewriteContext context);
- }
- public class RewriteRule : IRule {
{
- public RewriteRule(string regex, string replacement, bool stopProcessing);
- public Regex InitialMatch { get; }
- public string Replacement { get; }
- public bool StopProcessing { get; }
- public virtual void ApplyRule(RewriteContext context);
- }
- public abstract class UrlAction {
{
- protected UrlAction();
- protected Pattern Url { get; set; }
- public abstract void ApplyAction(RewriteContext context, BackReferenceCollection ruleBackReferences, BackReferenceCollection conditionBackReferences);
- }
- public abstract class UrlMatch {
{
- protected UrlMatch();
- protected bool Negate { get; set; }
- public abstract MatchResults Evaluate(string input, RewriteContext context);
- }
- }
- namespace Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite {
{
- public class ApacheModRewriteRule : IRule {
{
- public ApacheModRewriteRule(UrlMatch initialMatch, IList<Condition> conditions, IList<UrlAction> urlActions);
- public IList<UrlAction> Actions { get; }
- public IList<Condition> Conditions { get; }
- public UrlMatch InitialMatch { get; }
- public virtual void ApplyRule(RewriteContext context);
- }
- public class Condition {
{
- public Condition();
- public Pattern Input { get; set; }
- public UrlMatch Match { get; set; }
- public bool OrNext { get; set; }
- public MatchResults Evaluate(RewriteContext context, BackReferenceCollection ruleBackReferences, BackReferenceCollection conditionBackReferences);
- }
- public static class ConditionEvaluator {
{
- public static MatchResults Evaluate(IEnumerable<Condition> conditions, RewriteContext context, BackReferenceCollection backReferences);
- public static MatchResults Evaluate(IEnumerable<Condition> conditions, RewriteContext context, BackReferenceCollection backReferences, bool trackAllCaptures);
- }
- public class ConditionPatternParser {
{
- public ConditionPatternParser();
- public ParsedModRewriteInput ParseActionCondition(string condition);
- }
- public enum ConditionType {
{
- IntComp = 3,
- PropertyTest = 1,
- Regex = 0,
- StringComp = 2,
- }
- public class CookieActionFactory {
{
- public CookieActionFactory();
- public ChangeCookieAction Create(string flagValue);
- }
- public class FileParser {
{
- public FileParser();
- public IList<IRule> Parse(TextReader input);
- }
- public class FlagParser {
{
- public FlagParser();
- public Flags Parse(string flagString);
- }
- public class Flags {
{
- public Flags();
- public Flags(IDictionary<FlagType, string> flags);
- public IDictionary<FlagType, string> FlagDictionary { get; }
- public string this[FlagType flag] { get; set; }
- public bool GetValue(FlagType flag, out string value);
- public bool HasFlag(FlagType flag);
- public void SetFlag(FlagType flag, string value);
- }
- public enum FlagType {
{
- Chain = 1,
- Cookie = 2,
- DiscardPath = 3,
- End = 5,
- Env = 4,
- EscapeBackreference = 0,
- Forbidden = 6,
- Gone = 7,
- Handler = 8,
- Last = 9,
- Next = 10,
- NoCase = 11,
- NoEscape = 12,
- NoSubReq = 13,
- NoVary = 14,
- Or = 15,
- PassThrough = 17,
- Proxy = 16,
- QSAppend = 18,
- QSDiscard = 19,
- QSLast = 20,
- Redirect = 21,
- Skip = 22,
- Type = 23,
- }
- public enum OperationType {
{
- Directory = 7,
- Equal = 1,
- Executable = 13,
- ExistingFile = 9,
- ExistingUrl = 12,
- Greater = 2,
- GreaterEqual = 3,
- Less = 4,
- LessEqual = 5,
- None = 0,
- NotEqual = 6,
- RegularFile = 8,
- Size = 11,
- SymbolicLink = 10,
- }
- public class ParsedModRewriteInput {
{
- public ParsedModRewriteInput();
- public ParsedModRewriteInput(bool invert, ConditionType conditionType, OperationType operationType, string operand);
- public ConditionType ConditionType { get; set; }
- public bool Invert { get; set; }
- public string Operand { get; set; }
- public OperationType OperationType { get; set; }
- }
- public class RuleBuilder {
{
- public RuleBuilder();
- public void AddAction(Pattern pattern, Flags flags);
- public void AddConditionFromParts(Pattern pattern, ParsedModRewriteInput input, Flags flags);
- public void AddMatch(ParsedModRewriteInput input, Flags flags);
- public void AddRule(string rule);
- public ApacheModRewriteRule Build();
- }
- public class RuleRegexParser {
{
- public RuleRegexParser();
- public ParsedModRewriteInput ParseRuleRegex(string regex);
- }
- public enum SegmentType {
{
- ConditionParameter = 2,
- Literal = 0,
- RuleParameter = 3,
- ServerParameter = 1,
- }
- public static class ServerVariables {
{
- public static PatternSegment FindServerVariable(string serverVariable, ParserContext context);
- }
- public class TestStringParser {
{
- public TestStringParser();
- public Pattern Parse(string testString);
- }
- public class Tokenizer {
{
- public Tokenizer();
- public IList<string> Tokenize(string rule);
- }
- }
- namespace Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite {
{
- public enum ActionType {
{
- AbortRequest = 4,
- CustomResponse = 3,
- None = 0,
- Redirect = 2,
- Rewrite = 1,
- }
- public class Condition {
{
- public Condition();
- public Pattern Input { get; set; }
- public UrlMatch Match { get; set; }
- public MatchResults Evaluate(RewriteContext context, BackReferenceCollection ruleBackReferences, BackReferenceCollection conditionBackReferences);
- }
- public class ConditionCollection : IEnumerable, IEnumerable<Condition> {
{
- public ConditionCollection();
- public ConditionCollection(LogicalGrouping grouping, bool trackAllCaptures);
- public int Count { get; }
- public LogicalGrouping Grouping { get; }
- public Condition this[int index] { get; }
- public bool TrackAllCaptures { get; }
- public void Add(Condition condition);
- public void AddConditions(IEnumerable<Condition> conditions);
- public IEnumerator<Condition> GetEnumerator();
- IEnumerator System.Collections.IEnumerable.GetEnumerator();
- }
- public static class ConditionEvaluator {
{
- public static MatchResults Evaluate(ConditionCollection conditions, RewriteContext context, BackReferenceCollection backReferences);
- }
- public class IISRewriteMap {
{
- public IISRewriteMap(string name);
- public string Name { get; }
- public string this[string key] { get; set; }
- }
- public class IISRewriteMapCollection : IEnumerable, IEnumerable<IISRewriteMap> {
{
- public IISRewriteMapCollection();
- public int Count { get; }
- public IISRewriteMap this[string key] { get; }
- public void Add(IISRewriteMap rewriteMap);
- public IEnumerator<IISRewriteMap> GetEnumerator();
- IEnumerator System.Collections.IEnumerable.GetEnumerator();
- }
- public class IISUrlRewriteRule : IRule {
{
- public IISUrlRewriteRule(string name, UrlMatch initialMatch, ConditionCollection conditions, UrlAction action);
- public IISUrlRewriteRule(string name, UrlMatch initialMatch, ConditionCollection conditions, UrlAction action, bool global);
- public UrlAction Action { get; }
- public ConditionCollection Conditions { get; }
- public bool Global { get; }
- public UrlMatch InitialMatch { get; }
- public string Name { get; }
- public virtual void ApplyRule(RewriteContext context);
- }
- public class InputParser {
{
- public InputParser();
- public InputParser(IISRewriteMapCollection rewriteMaps);
- public Pattern ParseInputString(string testString);
- public Pattern ParseInputString(string testString, UriMatchPart uriMatchPart);
- }
- public class InvalidUrlRewriteFormatException : FormatException {
{
- public InvalidUrlRewriteFormatException(XElement element, string message);
- public InvalidUrlRewriteFormatException(XElement element, string message, Exception innerException);
- public int LineNumber { get; }
- public int LinePosition { get; }
- }
- public enum LogicalGrouping {
{
- MatchAll = 0,
- MatchAny = 1,
- }
- public enum MatchType {
{
- IsDirectory = 2,
- IsFile = 1,
- Pattern = 0,
- }
- public enum PatternSyntax {
{
- ECMAScript = 0,
- ExactMatch = 2,
- Wildcard = 1,
- }
- public enum RedirectType {
{
- Found = 302,
- Permanent = 301,
- SeeOther = 303,
- Temporary = 307,
- }
- public static class RewriteMapParser {
{
- public static IISRewriteMapCollection Parse(XElement xmlRoot);
- }
- public static class RewriteTags {
{
- public const string Action = "action";
- public const string Add = "add";
- public const string AppendQueryString = "appendQueryString";
- public const string Conditions = "conditions";
- public const string Enabled = "enabled";
- public const string GlobalRules = "globalRules";
- public const string IgnoreCase = "ignoreCase";
- public const string Input = "input";
- public const string Key = "key";
- public const string LogicalGrouping = "logicalGrouping";
- public const string LogRewrittenUrl = "logRewrittenUrl";
- public const string Match = "match";
- public const string MatchPattern = "matchPattern";
- public const string MatchType = "matchType";
- public const string Name = "name";
- public const string Negate = "negate";
- public const string Pattern = "pattern";
- public const string PatternSyntax = "patternSyntax";
- public const string RedirectType = "redirectType";
- public const string Rewrite = "rewrite";
- public const string RewriteMap = "rewriteMap";
- public const string RewriteMaps = "rewriteMaps";
- public const string Rule = "rule";
- public const string Rules = "rules";
- public const string StatusCode = "statusCode";
- public const string StatusDescription = "statusDescription";
- public const string StatusReason = "statusReason";
- public const string StopProcessing = "stopProcessing";
- public const string SubStatusCode = "subStatusCode";
- public const string TrackAllCaptures = "trackAllCaptures";
- public const string Type = "type";
- public const string Url = "url";
- public const string Value = "value";
- }
- public static class ServerVariables {
{
- public static PatternSegment FindServerVariable(string serverVariable, ParserContext context, UriMatchPart uriMatchPart);
- }
- public class UriMatchCondition : Condition {
{
- public UriMatchCondition(InputParser inputParser, string input, string pattern, UriMatchPart uriMatchPart, bool ignoreCase, bool negate);
- }
- public enum UriMatchPart {
{
- Full = 0,
- Path = 1,
- }
- public class UrlRewriteFileParser {
{
- public UrlRewriteFileParser();
- public IList<IISUrlRewriteRule> Parse(TextReader reader);
- }
- public class UrlRewriteRuleBuilder {
{
- public UrlRewriteRuleBuilder();
- public bool Enabled { get; set; }
- public bool Global { get; set; }
- public string Name { get; set; }
- public UriMatchPart UriMatchPart { get; }
- public void AddUrlAction(UrlAction action);
- public void AddUrlCondition(Condition condition);
- public void AddUrlConditions(IEnumerable<Condition> conditions);
- public void AddUrlMatch(string input, bool ignoreCase = true, bool negate = false, PatternSyntax patternSyntax = PatternSyntax.ECMAScript);
- public IISUrlRewriteRule Build();
- public void ConfigureConditionBehavior(LogicalGrouping logicalGrouping, bool trackAllCaptures);
- }
- }
- namespace Microsoft.AspNetCore.Rewrite.Internal.PatternSegments {
{
- public class ConditionMatchSegment : PatternSegment {
{
- public ConditionMatchSegment(int index);
- public override string Evaluate(RewriteContext context, BackReferenceCollection ruleBackReferences, BackReferenceCollection conditionBackReferences);
- }
- public class DateTimeSegment : PatternSegment {
{
- public DateTimeSegment(string segment);
- public override string Evaluate(RewriteContext context, BackReferenceCollection ruleBackReferences, BackReferenceCollection conditionBackReference);
- }
- public class HeaderSegment : PatternSegment {
{
- public HeaderSegment(string header);
- public override string Evaluate(RewriteContext context, BackReferenceCollection ruleBackReferences, BackReferenceCollection conditionBackReferences);
- }
- public class IsHttpsModSegment : PatternSegment {
{
- public IsHttpsModSegment();
- public override string Evaluate(RewriteContext context, BackReferenceCollection ruleBackReferences, BackReferenceCollection conditionBackReferences);
- }
- public class IsHttpsUrlSegment : PatternSegment {
{
- public IsHttpsUrlSegment();
- public override string Evaluate(RewriteContext context, BackReferenceCollection ruleBackReferences, BackReferenceCollection conditionBackReferences);
- }
- public class IsIPV6Segment : PatternSegment {
{
- public IsIPV6Segment();
- public override string Evaluate(RewriteContext context, BackReferenceCollection ruleBackReferences, BackReferenceCollection conditionBackReferences);
- }
- public class LiteralSegment : PatternSegment {
{
- public LiteralSegment(string literal);
- public override string Evaluate(RewriteContext context, BackReferenceCollection ruleBackReferences, BackReferenceCollection conditionBackReferences);
- }
- public class LocalAddressSegment : PatternSegment {
{
- public LocalAddressSegment();
- public override string Evaluate(RewriteContext context, BackReferenceCollection ruleBackReferences, BackReferenceCollection conditionBackReferences);
- }
- public class LocalPortSegment : PatternSegment {
{
- public LocalPortSegment();
- public override string Evaluate(RewriteContext context, BackReferenceCollection ruleBackReferences, BackReferenceCollection conditionBackReferences);
- }
- public class QueryStringSegment : PatternSegment {
{
- public QueryStringSegment();
- public override string Evaluate(RewriteContext context, BackReferenceCollection ruleBackRefernces, BackReferenceCollection conditionBackReferences);
- }
- public class RemoteAddressSegment : PatternSegment {
{
- public RemoteAddressSegment();
- public override string Evaluate(RewriteContext context, BackReferenceCollection ruleBackReferences, BackReferenceCollection conditionBackReferences);
- }
- public class RemotePortSegment : PatternSegment {
{
- public RemotePortSegment();
- public override string Evaluate(RewriteContext context, BackReferenceCollection ruleBackReferences, BackReferenceCollection conditionBackReferences);
- }
- public class RequestFileNameSegment : PatternSegment {
{
- public RequestFileNameSegment();
- public override string Evaluate(RewriteContext context, BackReferenceCollection ruleBackReferences, BackReferenceCollection conditionBackReferences);
- }
- public class RequestMethodSegment : PatternSegment {
{
- public RequestMethodSegment();
- public override string Evaluate(RewriteContext context, BackReferenceCollection ruleBackReferences, BackReferenceCollection conditionBackReferences);
- }
- public class RewriteMapSegment : PatternSegment {
{
- public RewriteMapSegment(IISRewriteMap rewriteMap, Pattern pattern);
- public override string Evaluate(RewriteContext context, BackReferenceCollection ruleBackReferences, BackReferenceCollection conditionBackReferences);
- }
- public class RuleMatchSegment : PatternSegment {
{
- public RuleMatchSegment(int index);
- public override string Evaluate(RewriteContext context, BackReferenceCollection ruleBackReferences, BackReferenceCollection conditionBackReferences);
- }
- public class SchemeSegment : PatternSegment {
{
- public SchemeSegment();
- public override string Evaluate(RewriteContext context, BackReferenceCollection ruleBackReferences, BackReferenceCollection conditionBackReferences);
- }
- public class ServerProtocolSegment : PatternSegment {
{
- public ServerProtocolSegment();
- public override string Evaluate(RewriteContext context, BackReferenceCollection ruleBackReferences, BackReferenceCollection conditionBackReferences);
- }
- public class ToLowerSegment : PatternSegment {
{
- public ToLowerSegment(Pattern pattern);
- public override string Evaluate(RewriteContext context, BackReferenceCollection ruleBackReferences, BackReferenceCollection conditionBackReferences);
- }
- public class UrlEncodeSegment : PatternSegment {
{
- public UrlEncodeSegment(Pattern pattern);
- public override string Evaluate(RewriteContext context, BackReferenceCollection ruleBackReferences, BackReferenceCollection conditionBackReferences);
- }
- public class UrlSegment : PatternSegment {
{
- public UrlSegment();
- public UrlSegment(UriMatchPart uriMatchPart);
- public override string Evaluate(RewriteContext context, BackReferenceCollection ruleBackReferences, BackReferenceCollection conditionBackReferences);
- }
- }
- namespace Microsoft.AspNetCore.Rewrite.Internal.UrlActions {
{
- public class AbortAction : UrlAction {
{
- public AbortAction();
- public override void ApplyAction(RewriteContext context, BackReferenceCollection ruleBackReferences, BackReferenceCollection conditionBackReferences);
- }
- public class ChangeCookieAction : UrlAction {
{
- public ChangeCookieAction(string name);
- public string Domain { get; set; }
- public bool HttpOnly { get; set; }
- public TimeSpan Lifetime { get; set; }
- public string Name { get; }
- public string Path { get; set; }
- public bool Secure { get; set; }
- public string Value { get; set; }
- public override void ApplyAction(RewriteContext context, BackReferenceCollection ruleBackReferences, BackReferenceCollection conditionBackReferences);
- }
- public class CustomResponseAction : UrlAction {
{
- public CustomResponseAction(int statusCode);
- public int StatusCode { get; }
- public string StatusDescription { get; set; }
- public string StatusReason { get; set; }
- public override void ApplyAction(RewriteContext context, BackReferenceCollection ruleBackReferences, BackReferenceCollection conditionBackReferences);
- }
- public class ForbiddenAction : UrlAction {
{
- public ForbiddenAction();
- public override void ApplyAction(RewriteContext context, BackReferenceCollection ruleBackReferences, BackReferenceCollection conditionBackReferences);
- }
- public class GoneAction : UrlAction {
{
- public GoneAction();
- public override void ApplyAction(RewriteContext context, BackReferenceCollection ruleBackReferences, BackReferenceCollection conditionBackReferences);
- }
- public class NoneAction : UrlAction {
{
- public NoneAction(RuleResult result);
- public RuleResult Result { get; }
- public override void ApplyAction(RewriteContext context, BackReferenceCollection ruleBackReferences, BackReferenceCollection conditionBackReferences);
- }
- public class RedirectAction : UrlAction {
{
- public RedirectAction(int statusCode, Pattern pattern, bool queryStringAppend);
- public RedirectAction(int statusCode, Pattern pattern, bool queryStringAppend, bool queryStringDelete, bool escapeBackReferences);
- public bool EscapeBackReferences { get; }
- public bool QueryStringAppend { get; }
- public bool QueryStringDelete { get; }
- public int StatusCode { get; }
- public override void ApplyAction(RewriteContext context, BackReferenceCollection ruleBackReferences, BackReferenceCollection conditionBackReferences);
- }
- public class RewriteAction : UrlAction {
{
- public RewriteAction(RuleResult result, Pattern pattern, bool queryStringAppend);
- public RewriteAction(RuleResult result, Pattern pattern, bool queryStringAppend, bool queryStringDelete, bool escapeBackReferences);
- public bool EscapeBackReferences { get; }
- public bool QueryStringAppend { get; }
- public bool QueryStringDelete { get; }
- public RuleResult Result { get; }
- public override void ApplyAction(RewriteContext context, BackReferenceCollection ruleBackReferences, BackReferenceCollection conditionBackReferences);
- }
- }
- namespace Microsoft.AspNetCore.Rewrite.Internal.UrlMatches {
{
- public class ExactMatch : UrlMatch {
{
- public ExactMatch(bool ignoreCase, string input, bool negate);
- public override MatchResults Evaluate(string pattern, RewriteContext context);
- }
- public class FileSizeMatch : UrlMatch {
{
- public FileSizeMatch(bool negate);
- public override MatchResults Evaluate(string input, RewriteContext context);
- }
- public class IntegerMatch : UrlMatch {
{
- public IntegerMatch(int value, IntegerOperationType operation);
- public IntegerMatch(string value, IntegerOperationType operation);
- public override MatchResults Evaluate(string input, RewriteContext context);
- }
- public enum IntegerOperationType {
{
- Equal = 0,
- Greater = 1,
- GreaterEqual = 2,
- Less = 3,
- LessEqual = 4,
- NotEqual = 5,
- }
- public class IsDirectoryMatch : UrlMatch {
{
- public IsDirectoryMatch(bool negate);
- public override MatchResults Evaluate(string pattern, RewriteContext context);
- }
- public class IsFileMatch : UrlMatch {
{
- public IsFileMatch(bool negate);
- public override MatchResults Evaluate(string pattern, RewriteContext context);
- }
- public class RegexMatch : UrlMatch {
{
- public RegexMatch(Regex match, bool negate);
- public override MatchResults Evaluate(string pattern, RewriteContext context);
- }
- public class StringMatch : UrlMatch {
{
- public StringMatch(string value, StringOperationType operation, bool ignoreCase);
- public override MatchResults Evaluate(string input, RewriteContext context);
- }
- public enum StringOperationType {
{
- Equal = 0,
- Greater = 1,
- GreaterEqual = 2,
- Less = 3,
- LessEqual = 4,
- }
- }
}