Announcements icon indicating copy to clipboard operation
Announcements copied to clipboard

Breaking change in IIS UrlRewrite support with query strings

Open jkotalik opened this issue 4 years ago • 1 comments

Changes to appendQueryString in IIS UrlRewrite middleware

We are fixing a bug in the IIS UrlRewrite middleware which will append query strings by default instead of removing them. This is to stay consistent with what the IIS UrlRewrite Module's behavior.

Version introduced

ASP.NET Core 5.0-preview7

Old behavior

When having a rewrite rule like the following:

<rule name="MyRule" stopProcessing="true">
  <match url="^foo" />
  <action type="Redirect" url="/bar" redirectType="Temporary" appendQueryString="true" /> <!-- appendQueryString defaults to true -->
</rule>

This wouldn't actually append the query string. So a URI like /foo?baz=1 wouldn't redirect to /bar?baz=1 and instead /bar. appendQueryString defaults to true as well.

New behavior

The new behavior fixes this behavior. Now the URI from the previous example would be /bar?baz=1.

Reason for change

The previous behavior didn't match the IIS UrlRewrite Module's behavior. Our goal is to have our IIS UrlRewrite middleware match the module as much as possible, so porting between is seamless.

Recommended action

If the behavior of removing the query string is preferred, you can change the action to have appendQueryString="false" instead.

Category

ASP.NET

Affected APIs

Microsoft.AspNetCore.Rewrite.IISUrlRewriteOptionsExtensions.AddIISUrlRewrite(RewriteOptions, IFileProvider, String)

Microsoft.AspNetCore.Rewrite.IISUrlRewriteOptionsExtensions.AddIISUrlRewrite(RewriteOptions, TextReader)

Microsoft.AspNetCore.Rewrite.IISUrlRewriteOptionsExtensions.AddIISUrlRewrite(RewriteOptions, TextReader, Boolean)

Microsoft.AspNetCore.Rewrite.IISUrlRewriteOptionsExtensions.AddIISUrlRewrite(RewriteOptions, IFileProvider, String, Boolean)

This is the discussion issue for the following announcement: https://github.com/dotnet/aspnetcore/issues/22972


Issue metadata

  • Issue type: breaking-change

jkotalik avatar Jun 15 '20 21:06 jkotalik

I am sorry if this is the wrong place to post this question but hopefully it will help clarify for others also. It sounds like the URL Rewrite functionality is included as middleware with .NET 5 and the module is no longer needed. Can you please clarify this? If so, is anything needed to enable it?

dbowser avatar Aug 19 '20 13:08 dbowser