Skip to content

Source server variables from IIS when running ANCM in-proc #10022

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

mderriey
Copy link
Contributor

@mderriey mderriey commented May 7, 2019

  • Source server variables from IIS when running ANCM in-proc

Addresses #6013

@mderriey
Copy link
Contributor Author

mderriey commented May 7, 2019

This is the first version to get something out there before asking too many questions.

Let me know if we'd like to support that or if you see anything else.

Copy link
Contributor

@analogrelay analogrelay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks OK to me. Minor suggestion around using a real type instead of a mock. Also not sure about adding the dependency. Now that it's one big happy <FrameworkReference>, it's probably not a big deal, but having to depend on Servers.IIS from Rewrite feels a little off.

Copy link
Contributor

@analogrelay analogrelay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks OK to me. Minor suggestion around using a real type instead of a mock. Also not sure about adding the dependency. Now that it's one big happy <FrameworkReference>, it's probably not a big deal, but having to depend on Servers.IIS from Rewrite feels a little off.

@analogrelay analogrelay added this to the 3.0.0-preview6 milestone May 7, 2019
@jkotalik jkotalik self-assigned this May 7, 2019
@mderriey mderriey force-pushed the 6013-source-server-variables-from-iis-when-running-ancm-in-proc branch from 4b997b1 to 2e90d8f Compare May 8, 2019 02:21
@mderriey mderriey force-pushed the 6013-source-server-variables-from-iis-when-running-ancm-in-proc branch from 9fedfd5 to 0333d78 Compare May 9, 2019 10:17
@davidfowl
Copy link
Member

I think we should move this feature to the features assembly in Http/*

@mderriey
Copy link
Contributor Author

Hey @davidfowl thanks for jumping in.

What feature are you referring to exactly?

@Tratcher
Copy link
Member

Tratcher commented May 10, 2019

@mderriey he's talking about moving IServerVariablesFeature so we can avoid the IIS server dependency. We'd also need to move GetIISServerVariable, or not use it in this code path.

@analogrelay
Copy link
Contributor

That would be a breaking change, but I think I'm OK with it. It seems reasonable. Server Variables aren't actually an IIS-specific concept anyway. They date back to CGI so it seems reasonable that other servers may want to provide them.

If we do this, I'd consider renaming the extension method to GetServerVariable instead of GetIISServerVariable.

@davidfowl
Copy link
Member

That would be a breaking change, but I think I'm OK with it. It seems reasonable. Server Variables aren't actually an IIS-specific concept anyway. They date back to CGI so it seems reasonable that other servers may want to provide them.

Exactly!

If we do this, I'd consider renaming the extension method to GetServerVariable instead of GetIISServerVariable.

Right! I think that's what we want to do for 3.0. Lets not hold up this PR as a result tho. File an issue and refactor this since most of these changes are related to the rewrite middleware.

@mderriey
Copy link
Contributor Author

Thanks for the explanation/context.

I'd be happy to try and implement the final solution to expand my knowledge of the codebase.

Could you please tag me in the resulting issue when it's created?

@analogrelay
Copy link
Contributor

Filing a bug now :)

@analogrelay
Copy link
Contributor

#10167

Feel free to move discussion on the subject of moving/renaming the feature to that issue.

@mderriey
Copy link
Contributor Author

Great, thanks. I'll wait until this PR is merged to start the move.

Thanks again.

@analogrelay
Copy link
Contributor

Code Check failed but I can't get AzDO to load. Usually this means you've got reference assemblies that are out of date. See https://github.com/aspnet/AspNetCore/blob/master/docs/ReferenceAssemblies.md for instructions on updating.

@analogrelay
Copy link
Contributor

Got it to load, yep, just need to update the refasms.

error: Generated code is not up to date in src/Middleware/Rewrite/ref/Microsoft.AspNetCore.Rewrite.netcoreapp3.0.cs. You might need to regenerate the reference assemblies or project list (see docs/ReferenceAssemblies.md and docs/ReferenceResolution.md)

@mderriey mderriey force-pushed the 6013-source-server-variables-from-iis-when-running-ancm-in-proc branch from 0333d78 to 3845ca8 Compare May 12, 2019 04:18
Copy link
Contributor

@jkotalik jkotalik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nits at this point 😄

Looks good, we can handle moving the feature to Http in a second PR.

I also want to do some E2E verification that this works when running inprocess.

@@ -19,7 +19,8 @@ public static class IISUrlRewriteOptionsExtensions
/// <param name="options">The <see cref="RewriteOptions"/></param>
/// <param name="fileProvider">The <see cref="IFileProvider"/> </param>
/// <param name="filePath">The path to the file containing UrlRewrite rules.</param>
public static RewriteOptions AddIISUrlRewrite(this RewriteOptions options, IFileProvider fileProvider, string filePath)
/// <param name="useNativeIISServerVariables">Server variables are sourced natively from IIS if the application uses the in-process hosting model; use <c>false</c> to disable that behavior</param>
public static RewriteOptions AddIISUrlRewrite(this RewriteOptions options, IFileProvider fileProvider, string filePath, bool useNativeIISServerVariables = true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public static RewriteOptions AddIISUrlRewrite(this RewriteOptions options, IFileProvider fileProvider, string filePath, bool useNativeIISServerVariables = true)
public static RewriteOptions AddIISUrlRewrite(this RewriteOptions options, IFileProvider fileProvider, string filePath, bool alwaysUseManagedServerVariables = false)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally we prefer bool defaults to be false.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries, thanks for pointing that out. I pushed extra commits to address that.

@@ -0,0 +1,21 @@
using System.Collections.Generic;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit copyright.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed 😇

@jkotalik
Copy link
Contributor

There are still test failures and I believe you need to re update references. That's the reason we are working on making things internal.

mderriey added 2 commits May 15, 2019 08:19
We inverted the meaning of the new boolean parameter
@mderriey
Copy link
Contributor Author

Hey @jkotalik, sorry about that. I forgot to invert the boolean values after we changed the meaning of the parameter. I also regenerated reference assemblies.

Sorry that this one drags out so much, I keep forgetting about the ref assemblies.

Thanks for your time, I'll keep an eye on the outcomes of the builds.

@jkotalik jkotalik merged commit 4a2bd2a into dotnet:master May 15, 2019
@jkotalik
Copy link
Contributor

Thanks @mderriey

@amcasey amcasey added area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlewares and removed area-runtime labels Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlewares
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants