Thank you for your interest in this project! As of 10th August 2024, we have decided to archive this repository. What does this mean?
Better approach to turn an ASP.NET Core Application Into Single Page Application using Ajax methodology. The main motto is to reduce developer's effort while working on creating a SPA and enhancing the Web app performance both on server and client side.
This library will apply on Asp.net core 3.1 to 6.0 solution.
Install following nuget package in your solution.
PM> Install-Package AjaxSpaMvcCore -Version 1.0.1
> dotnet add package AjaxSpaMvcCore --version 1.0.1
Go to Startup.cs file, Add the following middleware on Configure Method.
app.UseAjaxSpa();
Add the Ajax spa Tag helper referance on _ViewImports.cshtml file inside the View folder.
@addTagHelper *,AjaxSpaMvcCore
Note: Build the solution.
Go to _Layout.cshtml file, do the following process.
<script src="~/AjaxSpaResource/js/core.js"></script>
<script src="~/AjaxSpaResource/js/spa.js"></script>
<main role="main" class="pb-3">
@*@RenderBody()*@
<ajax-spa render-body="@RenderBody()"></ajax-spa>
</main>
Apply layout page by using ApplyLayoutAsync() extension method in the _ViewStart.cshtml file.
@using AjaxSpaMvcCore
@{
//Layout = "_Layout";
Layout = await Context.Request.ApplyLayoutAsync("~/Views/Shared/_Layout.cshtml");
}