aspnet / BasicMiddleware

[Archived] Basic middleware components for ASP.NET Core. Project moved to https://github.com/aspnet/AspNetCore
Apache License 2.0
169 stars 84 forks source link

Support REQUEST_METHOD variable in IIS URL Rewrite file parsing #191

Closed DamianEdwards closed 6 years ago

DamianEdwards commented 7 years ago

We should support the {REQUEST_METHOD} variable when parsing IIS URL Rewrite files. If there's a code equivalent we should support it there too of course. It represents the current request verb (e.g. 'get', 'head', 'post', etc.).

As it stands, the rules in live.asp.net aren't supported.

DamianEdwards commented 7 years ago

@muratg @glennc

davidfowl commented 7 years ago

Wondering what other missing server variables there are....

DamianEdwards commented 7 years ago

image

jkotalik commented 7 years ago

I blame documentation even though it is like 90% my fault XD

davidpeden3 commented 7 years ago

@Tratcher

fixed in https://github.com/aspnet/BasicMiddleware/pull/184/commits/3c8f2d40004ab926e899f567ef75e05034230443

Eilon commented 7 years ago

This patch bug is approved. Please use the normal code review process w/ a PR and make sure the fix is in the correct branch, then close the bug and mark it as done.

Eilon commented 7 years ago

@muratg please assign this bug.

mikaelm12 commented 7 years ago

Fixed in https://github.com/aspnet/BasicMiddleware/pull/201

KallDrexx commented 6 years ago

Did this get removed? After upgrading our Asp.net core project from 1.1 to 2.0 (using the AspnetCore.All package) I now get the following error:

System.FormatException: Unrecognized parameter type: 'REQUEST_METHOD', terminated at string index: '15'
   at Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite.ServerVariables.FindServerVariable(String serverVariable, ParserContext context, UriMatchPart uriMatchPart)
   at Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite.InputParser.ParseParameter(ParserContext context, IList`1 results, UriMatchPart uriMatchPart)
   at Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite.InputParser.ParseString(ParserContext context, UriMatchPart uriMatchPart)
   at Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite.InputParser.ParseInputString(String testString, UriMatchPart uriMatchPart)
   at Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite.UriMatchCondition..ctor(InputParser inputParser, String input, String pattern, UriMatchPart uriMatchPart, Boolean ignoreCase, Boolean negate)
   at Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite.UrlRewriteFileParser.ParseCondition(XElement conditionElement, UrlRewriteRuleBuilder builder, PatternSyntax patternSyntax)
   at Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite.UrlRewriteFileParser.ParseConditions(XElement conditions, UrlRewriteRuleBuilder builder, PatternSyntax patternSyntax)
   at Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite.UrlRewriteFileParser.ParseRuleAttributes(XElement rule, UrlRewriteRuleBuilder builder)
   at Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite.UrlRewriteFileParser.ParseRules(XElement rules, IList`1 result, Boolean global)
   at Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite.UrlRewriteFileParser.Parse(TextReader reader)
   at Microsoft.AspNetCore.Rewrite.IISUrlRewriteOptionsExtensions.AddIISUrlRewrite(RewriteOptions options, TextReader reader)
   at Microsoft.AspNetCore.Rewrite.IISUrlRewriteOptionsExtensions.AddIISUrlRewrite(RewriteOptions options, IFileProvider fileProvider, String filePath)
......

when calling rewriteOptions.AddIISUrlRewrite(env.ContentRootFileProvider, file);

Our rewrite definition file has <add input="{REQUEST_METHOD}" pattern="GET" ignoreCase="true" />

jkotalik commented 6 years ago

@KallDrexx seems you are right. It was added to the 1.0/1.1 branch https://github.com/aspnet/BasicMiddleware/commits/release/1.1 but not the 2.0 branch https://github.com/aspnet/BasicMiddleware/commits/release/2.0?after=8fd34cbb2f62cdf43a892289439b4bdf54ff9699+69. Seems to also not be in dev. @mikaelm12 can you forward port this change? cc/ @muratg we probably want to patch this for 2.0.x and add this back into dev as it was patched in the 1.1.x chain.

DamianEdwards commented 6 years ago

Agree this should be patched in 2.0.x

mikaelm12 commented 6 years ago

Do we want to sneak this into preview1? @DamianEdwards @muratg

DamianEdwards commented 6 years ago

If the port is straightforward and can be done simply and safely, then it'd be good to get this in preview1

Eilon commented 6 years ago

Can we get bugs logged for EACH applicable milestone, and then close this bug?

mikaelm12 commented 6 years ago

Can we get bugs logged for EACH applicable milestone

We don't have a 2.0.7 milestone though yet, right? Because this wouldn't be going into 2.0.6? Should I just go ahead and add the milestone?

Eilon commented 6 years ago

Put in 2.0.6 for now.

mikaelm12 commented 6 years ago

This is now being tracked in #292 and #293