diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/ServerVariables.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/ServerVariables.cs index 2b44331a15..afb3a72053 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/ServerVariables.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/ServerVariables.cs @@ -38,51 +38,51 @@ namespace Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite case "HTTP_FORWARDED": return new HeaderSegment("Forwarded"); case "AUTH_TYPE": - throw new NotSupportedException("Rules using the AUTH_TYPE server variable are not supported"); + throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable)); case "CONN_REMOTE_ADDR": return new RemoteAddressSegment(); case "CONTEXT_PREFIX": - throw new NotSupportedException("Rules using the CONTEXT_PREFIX server variable are not supported"); + throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable)); case "CONTEXT_DOCUMENT_ROOT": - throw new NotSupportedException("Rules using the CONTEXT_DOCUMENT_ROOT server variable are not supported"); + throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable)); case "IPV6": return new IsIPV6Segment(); case "PATH_INFO": - throw new NotImplementedException("Rules using the PATH_INFO server variable are not implemented"); + throw new NotImplementedException(Resources.FormatError_UnsupportedServerVariable(serverVariable)); case "QUERY_STRING": return new QueryStringSegment(); case "REMOTE_ADDR": return new RemoteAddressSegment(); case "REMOTE_HOST": - throw new NotSupportedException("Rules using the REMOTE_HOST server variable are not supported"); + throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable)); case "REMOTE_IDENT": - throw new NotSupportedException("Rules using the REMOTE_IDENT server variable are not supported"); + throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable)); case "REMOTE_PORT": return new RemotePortSegment(); case "REMOTE_USER": - throw new NotSupportedException("Rules using the REMOTE_USER server variable are not supported"); + throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable)); case "REQUEST_METHOD": return new RequestMethodSegment(); case "SCRIPT_FILENAME": return new RequestFileNameSegment(); case "DOCUMENT_ROOT": - throw new NotSupportedException("Rules using the DOCUMENT_ROOT server variable are not supported"); + throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable)); case "SCRIPT_GROUP": - throw new NotSupportedException("Rules using the SCRIPT_GROUP server variable are not supported"); + throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable)); case "SCRIPT_USER": - throw new NotSupportedException("Rules using the SCRIPT_USER server variable are not supported"); + throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable)); case "SERVER_ADDR": return new LocalAddressSegment(); case "SERVER_ADMIN": - throw new NotSupportedException("Rules using the SERVER_ADMIN server variable are not supported"); + throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable)); case "SERVER_NAME": - throw new NotSupportedException("Rules using the SERVER_NAME server variable are not supported"); + throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable)); case "SERVER_PORT": return new LocalPortSegment(); case "SERVER_PROTOCOL": return new ServerProtocolSegment(); case "SERVER_SOFTWARE": - throw new NotSupportedException("Rules using the SERVER_SOFTWARE server variable are not supported"); + throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable)); case "TIME_YEAR": return new DateTimeSegment(serverVariable); case "TIME_MON": @@ -100,13 +100,13 @@ namespace Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite case "TIME": return new DateTimeSegment(serverVariable); case "API_VERSION": - throw new NotSupportedException("Rules using the API_VERSION server variable are not supported"); + throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable)); case "HTTPS": return new IsHttpsModSegment(); case "HTTP2": - throw new NotSupportedException("Rules using the HTTP2 server variable are not supported"); + throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable)); case "IS_SUBREQ": - throw new NotSupportedException("Rules using the IS_SUBREQ server variable are not supported"); + throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable)); case "REQUEST_FILENAME": return new RequestFileNameSegment(); case "REQUEST_SCHEME": @@ -114,7 +114,7 @@ namespace Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite case "REQUEST_URI": return new UrlSegment(); case "THE_REQUEST": - throw new NotSupportedException("Rules using the THE_REQUEST server variable are not supported"); + throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable)); default: throw new FormatException(Resources.FormatError_InputParserUnrecognizedParameter(serverVariable, context.Index)); } diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/ServerVariables.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/ServerVariables.cs index a9c92a9a6c..12367e142c 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/ServerVariables.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/ServerVariables.cs @@ -15,9 +15,9 @@ namespace Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite { // TODO Add all server variables here. case "ALL_RAW": - throw new NotSupportedException("Rules using the ALL_RAW server variable are not supported"); + throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable)); case "APP_POOL_ID": - throw new NotSupportedException("Rules using the APP_POOL_ID server variable are not supported"); + throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable)); case "CONTENT_LENGTH": return new HeaderSegment(HeaderNames.ContentLength); case "CONTENT_TYPE": @@ -41,13 +41,13 @@ namespace Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite case "LOCAL_ADDR": return new LocalAddressSegment(); case "HTTP_PROXY_CONNECTION": - throw new NotSupportedException("Rules using the HTTP_PROXY_CONNECTION server variable are not supported"); + throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable)); case "QUERY_STRING": return new QueryStringSegment(); case "REMOTE_ADDR": return new RemoteAddressSegment(); case "REMOTE_HOST": - throw new NotSupportedException("Rules using the REMOTE_HOST server variable are not supported"); + throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable)); case "REMOTE_PORT": return new RemotePortSegment(); case "REQUEST_FILENAME": diff --git a/src/Microsoft.AspNetCore.Rewrite/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Rewrite/Properties/Resources.Designer.cs index bda94e5268..f52b4232a8 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Properties/Resources.Designer.cs @@ -202,6 +202,22 @@ namespace Microsoft.AspNetCore.Rewrite return string.Format(CultureInfo.CurrentCulture, GetString("Error_UrlRewriteParseError"), p0, p1, p2); } + /// + /// Rules using the '{0}' server variable are not supported + /// + internal static string Error_UnsupportedServerVariable + { + get { return GetString("Error_UnsupportedServerVariable"); } + } + + /// + /// Rules using the '{0}' server variable are not supported + /// + internal static string FormatError_UnsupportedServerVariable(object p0) + { + return string.Format(CultureInfo.CurrentCulture, GetString("Error_UnsupportedServerVariable"), p0); + } + private static string GetString(string name, params string[] formatterNames) { var value = _resourceManager.GetString(name); diff --git a/src/Microsoft.AspNetCore.Rewrite/Resources.resx b/src/Microsoft.AspNetCore.Rewrite/Resources.resx index 2c68d33ec3..7574b71b2f 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Resources.resx +++ b/src/Microsoft.AspNetCore.Rewrite/Resources.resx @@ -1,17 +1,17 @@  - @@ -153,4 +153,7 @@ Could not parse the UrlRewrite file. Message: '{0}'. Line number '{1}': '{2}'. + + Rules using the '{0}' server variable are not supported + \ No newline at end of file