Skip to content

Debugging Under IIS #30378

Closed
Closed

Description

@vbjay

Problem

This fails if you are debugging on IIS and not using IIsExpress. Reasons:

  • current profile being used in iis would be the user profile for the apppool
  • load user profile in app pool must be turned on
  • The Visual Studio manage user secrets and dotnet user-secrets set both touch the user's %APPDATA% that is running the tool so this means you are not modifying the correct secrets.json

The WHOLE point of having it write to an out of repo file is that you didn't want to check in the secrets into the repo.

Fix

Add --iis and --iisDebugProfile options to dotnet user-secrets set that tell it to look up the correct site/apppool and determine the correct user profile path to write the secrets.json. Along with adjusting the secrets provider to write settings like the following sample if --iis was used so that just in case same profile was used in multiple sites you still have secret ID specific settings. iisDebugProfile woulld allow you to pick the right site from the launchsettings.json in the project.

{
    "113dbdab-7d0c-40d8-9793-c86e77ebdbc8":{
        "secret 1 Path":"Secret 1 Value",
        "secret 2 Path":"Secret 2 Value"
    }
}

Document Details

⚠ Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

Activity

  1. added
    Source - Docs.ms
    on Sep 15, 2023
  2. vbjay commented on Sep 15, 2023

    @vbjay
    Author

    See #16328 for related and mentioned in article. I frankly think a section in the docs should talk about this issue instead of an easily missed link. Something like

    Using Secrets in IIS vs IISExpress

    If running in IIS, the fileprovider looks in the website folder. The recommendation is to create a secrets.json file in the project and add to .gitignore to prevent checking in the secrets.


    I still think the tooling could be better to manage the correct secrets.json file.

  3. Rick-Anderson commented on Sep 19, 2023

    @Rick-Anderson
    Contributor

    Add --iis and --iisDebugProfile options to dotnet user-secrets

    We're a documentation repo. Feel free to open a suggestion issue at https://github.com/dotnet/aspnetcore/tree/main/src/Tools/dotnet-user-secrets

  4. Rick-Anderson commented on Sep 19, 2023

    @Rick-Anderson
    Contributor

    The WHOLE point of having it write to an out of repo file is that you didn't want to check in the secrets into the repo.

    Why do you need to check in secrets to the repo?

  5. vbjay commented on Sep 19, 2023

    @vbjay
    Author

    Re read what I said. You are not reading what I said correctly.

    Screenshot_20230919-184451_GitHub.jpg

    Screenshot_20230919-184444_GitHub.jpg

  6. vbjay commented on Sep 19, 2023

    @vbjay
    Author

    Add --iis and --iisDebugProfile options to dotnet user-secrets

    We're a documentation repo. Feel free to open a suggestion issue at https://github.com/dotnet/aspnetcore/tree/main/src/Tools/dotnet-user-secrets

    Thanks. I'll do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Source - Docs.msdoc-bugdoc-enhancement

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions