Project Templates
The PowerPortalsPro project template scaffolds a complete Blazor portal with Dataverse connectivity, authentication, security handlers, localization, and pre-built identity pages — ready to run in minutes. You choose the interactivity mode (Server, WebAssembly, or Auto) when scaffolding and the template wires up the right project layout for you.
Installing the Template
Install the PowerPortalsPro.AspNetCore.Templates package from NuGet using the .NET CLI:
dotnet new install PowerPortalsPro.AspNetCore.Templates
Creating a New Project
Once installed, create a new project using the CLI or from Visual Studio's "New Project" dialog by searching for "Power Portals Pro". The optional --interactivity flag selects the Blazor render mode — see the next section for the three choices. When omitted it defaults to Server.
dotnet new powerportalspro -o MyPortal --interactivity Auto
Choosing an Interactivity Mode
The template accepts --interactivity Server, --interactivity WebAssembly, or --interactivity Auto. Picking a mode up front only affects the generated project layout — PowerPortalsPro itself runs correctly under all three.
- Server — interactive pages execute on the server over a SignalR connection. Simplest deployment and smallest client download. Good default when you're unsure.
- WebAssembly — interactive pages run in the browser as compiled .NET code. Scaffolds a separate
.Clientproject; the server hosts the API endpoints consumed by the client. Best for rich client-side UX and offloading interaction work from the server. - Auto — renders the first paint on the server for fast perceived load, then transparently hands off to WebAssembly once the client bundle is downloaded. Combines the best of both at the cost of a slightly more complex project layout.
Tip
The
--interactivityflag matches the stockdotnet new blazortemplate's flag of the same name, so anything you already know about Blazor render modes carries over.
What's Included
The template generates a fully functional portal project with the following:
- Sample Pages — Accounts and Contacts list pages with MainGrid, plus detail pages with RecordContext, editors, and SubGrids.
- Identity Pages — Complete ASP.NET Core Identity integration with Login, Register, Forgot Password, Reset Password, Two-Factor Authentication, Email Confirmation, and account management pages.
- Security Handlers — Pre-built permission handlers for the Account and Contact tables demonstrating table-level and record-level security patterns.
- Layout — A MainLayout with PageLayout, desktop and mobile navigation menus, site settings, and theme support.
- Localization — A JSON localization file (
app.en.json) with navigation labels and page-specific strings. - Configuration —
appsettings.jsonwith placeholders for Dataverse connection settings.
Understanding Program.cs
The Program.cs file is where all services are registered and the application pipeline is configured. Here is a breakdown of each section:
Distributed Cache
The template registers a memory-based distributed cache. In production, replace this with a persistent cache like Redis or SQL Server for better performance across multiple instances.
builder.Services.AddDistributedMemoryCache();
Fluent UI Registration
AddPowerPortalsProWebBlazorFluentUI() registers all Fluent UI Blazor components used by PowerPortalsPro editors, grids, and layout components.
builder.Services.AddPowerPortalsProWebBlazorFluentUI();
Server Services
AddPowerPortalsProWebServer() registers the core server-side services including the Dataverse data access layer, security enforcement, interceptor pipeline, and localization loading.
builder.Services.AddPowerPortalsProWebServer()
Dataverse Connection
The ConnectionOptions configuration specifies how the portal authenticates with Dataverse. The template uses Client Secret authentication with credentials stored in appsettings.json or User Secrets.
.Configure<ConnectionOptions>((options) =>
{
options.AuthenticationType = AuthenticationType.ClientSecret;
options.ServiceUri = new Uri(builder.Configuration.GetRequiredValue("D365:Url"));
options.ClientId = builder.Configuration.GetRequiredValue("D365:ClientId");
options.ClientSecret = builder.Configuration.GetRequiredValue("D365:Secret");
})
Tip
For security best practices, store your credentials in User Secrets during development and Azure Key Vault or environment variables in production. Never commit secrets to source control.
Localization Configuration
AddLocalizationDirectory registers directories containing localization JSON files. By default LocalizeAllAvailableTables is true, so labels, column names, and view names are pulled from every Dataverse table automatically. Set it to false and use AddTableToLocalize / AddTablesToLocalize to restrict localization to an explicit list.
.Configure<LocalizationOptions>(options =>
{
options.AddLocalizationDirectory("localization");
// By default, every Dataverse table is localized. To restrict
// localization to an explicit list, opt out and add the tables:
//options.LocalizeAllAvailableTables = false;
//options.AddTablesToLocalize(new List<string> { "transactioncurrency", "opportunity" });
})
Identity Options
The IdentityOptions section configures ASP.NET Core Identity settings such as requiring email confirmation before login.
.Configure<IdentityOptions>(options =>
{
options.SignIn.RequireConfirmedAccount = true;
})
Security Handler Registration
Permission handlers are registered in the DI container to control CRUD access for each table. The template includes handlers for Account (full access) and Contact (read-only with owner-based updates).
builder.Services.AddTransient<ITablePermissionHandler, AccountTablePermissionHandler>();
builder.Services.AddTransient<ITableRecordPermissionHandler, ContactTablePermissionHandler>();
builder.Services.AddTransient<ITableRecordPermissionHandler, ExternalLoginPermissionHandler>();
Email Configuration
The EmailServiceOptions configures the sender email address used for account confirmation and password reset emails. This is sent via the Dataverse email service.
builder.Services.Configure<EmailServiceOptions>(options =>
{
options.EmailSenderEmailAddress = builder.Configuration
.GetRequiredValue("D365:EmailSenderEmailAddress");
});
Microsoft Authentication (Optional)
The template includes commented-out code for adding Microsoft Entra ID (Azure AD) authentication. Uncomment and configure your Client ID and Secret to enable external login via Microsoft accounts.
builder.Services.AddAuthentication().AddMicrosoftAccount(microsoftOptions =>
{
microsoftOptions.ClientId = builder.Configuration
.GetRequiredValue("Authentication:Microsoft:ClientId");
microsoftOptions.ClientSecret = builder.Configuration
.GetRequiredValue("Authentication:Microsoft:ClientSecret");
});
Middleware Pipeline
UsePowerPortalsProWebServer() adds the PowerPortalsPro middleware. UseLocalization() enables the localization system. MapAdditionalIdentityEndpoints() registers the cookie-based login endpoint used by the identity pages.
app.UsePowerPortalsProWebServer();
app.UseLocalization();
app.MapAdditionalIdentityEndpoints();
Two-Factor Authentication (Optional)
The template includes commented-out code for enabling Two-Factor Authentication using email-based codes. Uncomment the AuthenticatorTokenProvider option and the AddDefaultTokenProviders() call to enable it.
// In Configure<IdentityOptions>:
options.Tokens.AuthenticatorTokenProvider = TokenOptions.DefaultEmailProvider;
// After the main service registration:
builder.Services.AddIdentityCore<Contact>()
.AddDefaultTokenProviders();
Common Customizations
After scaffolding the project, here are common next steps:
- Add permission handlers for any additional Dataverse tables your portal accesses.
- Every Dataverse table is localized by default. To opt out for a smaller footprint, set
LocalizeAllAvailableTablestofalseand list the tables you want viaAddTableToLocalize. - Register
ITableRecordInterceptorimplementations for business logic that runs before or after record operations. - Update the navigation menus in
NavMenu.razor,DesktopNavMenu.razor, andMobileNavMenu.razorto match your portal's pages. - Add new pages with
RecordContext, editors, and grids for your custom Dataverse tables.
