Skip to content

Commit c61d627

Browse files
authored
Merge pull request #49 from fingers10/master
Update README.md with example for reading host environment
2 parents df86c75 + 2e8126c commit c61d627

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,22 @@ This is important for your Blazor WebAssembly components to work fine in the pre
5959

6060
The `ConfigureServices(...)` static local function can also have an `IConfiguration` argument that reflects the contents of the `wwwroot/appsetting.json` JSON file.
6161

62+
The prerendering package supposes that the `ConfigureServices` method has no or only one `string` argument and that the string argument means the app's base address if there is one. The package doesn't suppose that the `ConfigureServices` method has two or more string parameters and can't determine those argument names. (The argument names of methods are usually minified at the publishing time.)
63+
64+
If you need to pass the environment name to the `ConfigureServices`, please pass the `IWebAssemblyHostEnvironment` to its argument like this.
65+
66+
```cs
67+
// Program.cs
68+
...
69+
ConfigureServices(builder.Services, builder.HostEnvironment, builder.Configuration);
70+
...
71+
static void ConfigureServices(IServiceCollection services, IWebAssemblyHostEnvironment webHostEnv, IConfiguration configuration)
72+
{
73+
// You can get the environment name via "webHostEnv.Environment".
74+
// You can also get the app base address via "webHostEnv.BaseAddress".
75+
...
76+
```
77+
6278
### Root component type and selector
6379

6480
In some cases, suppose the type and selector of the root component of your Blazor WebAssembly app are not `{RootNamespace}.App` and `#app` or `app`.

0 commit comments

Comments
 (0)