Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Blazer Server App - Add web.config settings

I have a Blazor Server app that is running under IIS. I see that it generates a web.config file upon publish with some settings in it.

I need to add some more settings to the web.config as they are used by another component (asp.net 4 app). Does anyone know which file I need to create/modify in order to be able to add these values.

At this stage I do not need to use transforms on the web.config, but it would be nice to know this as well.

like image 838
AndyW Avatar asked Nov 01 '25 21:11

AndyW


2 Answers

What I found is that the web.config works as per Asp.Net Core documentation. In brief for a Blazor server app hosted under IIS (this is my understanding)

  • If there is no web.config existing in the root of the project directory, one is created during the build and copied to the bin directory. It will contain default information.
  • If a web.config exists in the root of the project directory, it is copied to the bin folder unmodified (note: it requires some default settings inside).
  • If transforms exist, they will be applied.

I didn't realise that the web.config is created if it did not exist hence my original question.

Also, I have not been able to get transforms to work yet.

like image 91
AndyW Avatar answered Nov 03 '25 18:11

AndyW


I found that if you publish the project the web.config in the root gets ignored and uses the auto-generated one.

Adding this to my blazor project file solved it and can see the web.config getting published to Azure now:

<PropertyGroup>
    <PublishIISAssets>true</PublishIISAssets>
like image 31
Rob C Avatar answered Nov 03 '25 18:11

Rob C