Inertia.Net.Mvc
1.5.3
dotnet add package Inertia.Net.Mvc --version 1.5.3
NuGet\Install-Package Inertia.Net.Mvc -Version 1.5.3
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="Inertia.Net.Mvc" Version="1.5.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Inertia.Net.Mvc" Version="1.5.3" />
<PackageReference Include="Inertia.Net.Mvc" />
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 Inertia.Net.Mvc --version 1.5.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Inertia.Net.Mvc, 1.5.3"
#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 Inertia.Net.Mvc@1.5.3
#: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=Inertia.Net.Mvc&version=1.5.3
#tool nuget:?package=Inertia.Net.Mvc&version=1.5.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Inertia.Net.Mvc
Use the 1.5 packages together; from 1.3 or earlier, see the 1.4 upgrade notes. TempData state formats are unchanged.
MVC integration for Inertia.Net, a .NET 10 server adapter for the Inertia.js v3 protocol. Install it next to Inertia.Net:
dotnet add package Inertia.Net
dotnet add package Inertia.Net.Mvc
builder.Services.AddInertia();
builder.Services.AddControllersWithViews().AddInertiaMvc(o => o.UseRazorRootView("App")); // UseRazorRootView is optional
builder.Services.AddAntiforgery(o => o.HeaderName = InertiaHeaders.XsrfToken);
var app = builder.Build();
app.UseStaticFiles();
app.UseInertia();
app.UseInertiaAntiforgery(); // CSRF: XSRF-TOKEN cookie, 419 for mutations without a valid token
app.MapControllers();
public sealed class UsersController : Controller
{
[HttpGet("/users")]
public IResult Index() => Render("Users/Index", new InertiaProps { ["users"] = users }); // also Back(), Location(url)
[HttpPost("/users")]
public IActionResult Store([FromBody] CreateUserInput input) => Redirect("/users");
}
- Validation: a global filter redirects an Inertia non-GET request with an invalid
ModelStateback with the errors, in the bag named byX-Inertia-Error-Bag(defaultdefault). Keys go through the JSON naming policy per segment (Address.Streetbecomesaddress.street).[ApiController]controllers are covered too. - Razor root view (optional):
UseRazorRootView("App")rendersViews/Shared/App.cshtmlwith anInertiaRootViewContextmodel. After@addTagHelper *, Inertia.Net.Mvcthe view can use<inertia />,<inertia-head />,<vite entry="resources/js/app.tsx" />and<vite-react-refresh />. - TempData state store (optional):
AddInertiaMvc(o => o.UseTempDataStateStore())keeps flash data, errors and history flags in TempData (cookie provider by default, orAddSessionStateTempDataProvider()plusAddSession()/app.UseSession()beforeapp.UseInertia()). It also serves Minimal API endpoints. - Action components:
return this.InertiaView(props);renders{Controller}/{Action}({Area}/...in an area); change the rule withAddInertiaMvc(o => o.ComponentResolver = ctx => ...). - Not Native AOT compatible (MVC is not).
Documentation:
| Product | Versions 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.
-
net10.0
- Inertia.Net (>= 1.5.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.