# TodoTemplate

Blazor multi mode with best practices in mind!

In Directory.build.props, you can switch between blazor server / web assembly and hybrid by using either

```xml
<BlazorMode>BlazorWebAssembly</BlazorMode>
```

```xml
<BlazorMode>BlazorServer</BlazorMode>
```

```xml
<BlazorMode>BlazorHybrid</BlazorMode>
```

For blazor web assembly use followings in TodoTemplate.App:

```xml
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
```

for blazor server use:

```xml
<Project Sdk="Microsoft.NET.Sdk.Web">
```

For blazor hybrid, use Bit.Client.Web.BlazorUI.App project instead.

To run blazor web assembly only start Api project and use 'TodoTemplate.Api-BlazorWebAssembly' debug profile, but for blazor hybrid you need multi startup for both api & app projects. In blazor server you need multi startup for both api & web projects. In Blazor hybrid and server, use 'TodoTemplate.Api' debug profile for api project. For enhanced development experience, unload App project while debugging in server/web assembly modes and unload web project while debugging hybrid mode.

In shared project, you can also detect code is running in blazor server / web assembly or hybrid mode by use any of followings:

```cs
if (TodoTemplate.Shared.BlazorModeDetector.Current.IsBlazorServer())
{
}

#if BlazorWebAssembly

#endif
```

It's recommended to clear your browser's cache and close/open visual studio while switching between blazor modes!


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://bitfoundation.gitbook.io/bit-docs/src/tooling-1/bit.tooling.templates/todotemplate.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
