Skip to content

httpcontext.getiisservervariable always returns null in development #17055

@vsfeedback

Description

@vsfeedback

This issue has been moved from a ticket on Developer Community.


I am creating a web api in asp net core 2.2 which will be served from IIS and whose clients need access to some server variables. The docs for asp net core 2.2 describe the httpcontext extension method GetIISServerVaraible(string)

I am using IISExpress in process hosting for testing and this extension method just returns null. I imagine something needs to be doen to set the values in IIS Express, but I can't seem to find any information for how to do that. What am I missing?


Original Comments

Visual Studio Feedback System on 7/9/2019, 07:14 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

Vatsalya Agrawal [MSFT] on 7/15/2019, 04:55 PM:

Base on the documentation @ https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.server.iis.httpcontextextensions.getiisservervariable?view=aspnetcore-2.2

Returns null if the feature does not support the IServerVariablesFeature feature. May return null or empty if the variable does not exist or is not set.

Please let us know if this resolves your issue. If not please share sample code/project where this issue is occuring.

Pamela Thalacker on 7/16/2019, 11:10 AM:

I assume IIS supports the IServerVariablesFeature. Isn't there some way to mock it in IIS Express for testing?

Visual Studio Feedback System on 11/12/2019, 08:27 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

Andrew Stanton-Nurse on 11/12/2019, 08:40 PM:

I’m not aware of a reason this wouldn’t work in IIS Express, but I may be wrong 😃. Since this is an ASP.NET Core runtime issue, I’m going to move this to our GitHub repo so the team can investigate further.


Original Solutions

(no solutions)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsenhancementThis issue represents an ask for new feature or an enhancement to an existing onefeature-iisIncludes: IIS, ANCM

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions