1
votes

I have URL rewrite rules configured for production IIS application pool that do not work in the development IIS application pool (notably HTTP to HTTPS redirection).

What I have:

  • web.production.config for production
  • web.config (for development AND local IIS Express)
  • Two publish profiles (development and production).

What I need:

  • web.production.config to be published with the production publish profile.
  • web.config to be published with the development publish profile AND used by the local IIS express for local debugging.

What I currently do:

  1. Exclude both files from being published.
  2. Copy the web.production.config file manually after deployment, renaming it to web.config on the server.

How can I automate this? The <ExcludeFilesFromDeployment /> property in pubxml does not suppress the need for a renaming of the file after deployment.

1

1 Answers

0
votes

If you want to use web.config/IIS to achieve your redirects etc. then I would recommend using Web Config Transforms. See this post for help on how to add a transform for each of your environments. Web config transforms are easy to create/maintain and are automated as part of the publish process.

However, I would say that with .net Core there are many options for URL rewriting or enforcing HTTPS redirects from middleware which allow you to explicitly switch on the current environment. These tend to be preferred over reliance on IIS.