YAFNET.RazorPages 4.1.1

dotnet add package YAFNET.RazorPages --version 4.1.1
                    
NuGet\Install-Package YAFNET.RazorPages -Version 4.1.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="YAFNET.RazorPages" Version="4.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="YAFNET.RazorPages" Version="4.1.1" />
                    
Directory.Packages.props
<PackageReference Include="YAFNET.RazorPages" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add YAFNET.RazorPages --version 4.1.1
                    
#r "nuget: YAFNET.RazorPages, 4.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package YAFNET.RazorPages@4.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=YAFNET.RazorPages&version=4.1.1
                    
Install as a Cake Addin
#tool nuget:?package=YAFNET.RazorPages&version=4.1.1
                    
Install as a Cake Tool

YAFLogo

Ko-fi

YAF.NET Razor Pages Client Library

Prerequisites:

  • ASP.NET Core 10.0 (YAF v4.x)

Quick Guide

Add the YAF Nuget Packages

  1. Install the YAFNET.RazorPages Package via Nuget Browser or the console

NuGet

> dotnet add package YAFNET.RazorPages
  1. Depending on which Data Provider you want top use add the package ..

YAFNET.Data.SqlServer Package via Nuget Browser or the console

NuGet

> dotnet add package YAFNET.Data.SqlServer

YAF.Data.MySQL Package via Nuget Browser or the console

NuGet

> dotnet add package YAFNET.Data.MySQL

YAFNET.Data.PostgreSQL Package via Nuget Browser or the console

NuGet

> dotnet add package YAFNET.Data.PostgreSQL

YAFNET.Data.Sqlite Package via Nuget Browser or the console

NuGet

> dotnet add package YAFNET.Data.Sqlite

YAFNET.Data.Sqlite.Data Package via Nuget Browser or the console, SQLite with Microsoft.Data.Sqlite instead of System.Data.SQLite (also runs on ARM64, set "ConnectionProviderName": "Microsoft.Data.Sqlite")

NuGet

> dotnet add package YAFNET.Data.Sqlite.Data

Getting Started

Program.cs

In the Program.cs add the following.

 var builder = WebApplication.CreateBuilder(args);

builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory());

builder.Host.ConfigureYafLogging();

builder.Host.ConfigureContainer<ContainerBuilder>(containerBuilder =>
{
    containerBuilder.RegisterYafModules();
});

builder.Services.AddRazorPages(options =>
{
    options.Conventions.AddAreaPageRoute("Forums", "/SiteMap", "/Sitemap.xml");
}).AddYafRazorPages(builder.Environment);

builder.Services.AddYafCore(builder.Configuration, "/Forums");

// only needed for blazor
builder.Services.AddServerSideBlazor();

var app = builder.Build();

....

app.RegisterAutofac();

app.UseAntiXssMiddleware();

app.UseStaticFiles();

app.UseSession();

app.UseYafCore(BoardContext.Current.ServiceLocator, app.Environment);

app.UseRobotsTxt(app.Environment);

app.MapRazorPages();

app.MapAreaControllerRoute(
    name: "default",
    areaName: "Forums",
    pattern: "{controller=Home}/{action=Index}/{id?}");

app.MapControllers();

app.MapHub<NotificationHub>("/NotificationHub");
app.MapHub<ChatHub>("/ChatHub");

await app.RunAsync();

Now the Forum is ready and you can add a link to your _Layout.cshtml

 <li class="nav-item">
     <a class="nav-link" asp-area="Forums" asp-page="/Index">Forums</a>
 </li>

Host application manages the accounts

If the application has its own login and account pages, set HostManagesAccounts in the BoardConfiguration section of the appsettings.json.

"BoardConfiguration": {
    "HostManagesAccounts": true
}

If the application also sets up ASP.NET Core Identity itself, call AddYafCore with useHostIdentity: true. The forum then does not add the default identity, the identity options and its authentication cookie. The identity options keep their defaults unless you set them. Add the Identity.Application cookie before calling AddYafCore, for example with AddIdentity, because the forum refreshes and ends sign-ins with it. To keep the accounts in your own tables, register your own IUserStore<AspNetUsers> and IRoleStore<AspNetRoles>; they replace the forum stores.

builder.Services.AddIdentity<AspNetUsers, AspNetRoles>()
    .AddUserStore<MyUserStore>()
    .AddRoleStore<MyRoleStore>();

builder.Services.AddYafCore(builder.Configuration, "/Forums", useHostIdentity: true);

If the application has its own middleware pipeline (e.g. a CMS), use UseYafCoreForArea instead of UseYafCore. It is called after the routing, authentication and authorization of the application, and the forum middlewares (security headers, session, install check, banned IPs, the forum languages, rate limiter...) only run for the forum requests: the pages of the area and the controllers, pages and hubs of the forum. The static files, forwarded headers and https redirection stay with the application. Middlewares of the application for the forum requests (e.g. to create the forum user of a signed in account) are added with configureForumRequests: they run after the install check, with the session, before the forum loads the user of the page.

app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();

app.RegisterAutofac();
app.UseYafCoreForArea(BoardContext.Current.ServiceLocator);

The login and register links of the forum go to the Account/Login and Account/Register pages of the forum area (with the ReturnUrl), redirect them to the pages of your application.

Community Support Forum

See a real live YAF Forum by visiting the YetAnotherForum.NET community support forum: https://yetanotherforum.net/forums. Also, get your questions answered by the YAF community.

License

Yet Another Forum.NET is licensed under the Apache 2.0 license.

Yet Another Forum Community Support

If you have any questions, please visit the YAF Community Support forum: https://yetanotherforum.net/forums, or visit the Wiki for More Informations.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on YAFNET.RazorPages:

Package Downloads
YAFNET.Umbraco.Forums

Runs the YAF.NET (YetAnotherForum.NET) forum inside an Umbraco site, with single sign-on through Umbraco Members.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.1.1 137 11/30/2026
4.1.0 112 11/30/2026
4.0.11 180 11/14/2026
4.0.10 220 10/21/2026
4.0.9 196 8/30/2026
4.0.8 178 8/10/2026
4.0.7 175 8/2/2026
4.0.6 205 6/20/2026
4.0.5 294 4/26/2026
4.0.4 351 1/10/2026
4.0.2 457 9/24/2025
4.0.1 338 8/31/2025
4.0.0 634 3/16/2025
4.0.0-rc04 578 11/17/2024
4.0.0-rc03 830 7/6/2024
4.0.0-rc02 327 5/29/2024
4.0.0-rc01 310 5/29/2024
4.0.0-beta09 273 5/18/2024
4.0.0-beta07 285 3/28/2024
4.0.0-beta05 289 2/28/2024

## 🐞 Bug fixes
* Upgrade: the first request after updating a forum to 4.1.0 showed an error instead of upgrading the database ("No scope with a tag matching 'AutofacWebRequest' is visible"): the upgrade got the services of the application instead of those of the request, renaming the "Registered" role needs the role manager of the request