
C'est une méthode innovante pour transformer une application de base ASP.NET en une application à page unique, l'objectif est de réduire les efforts du développeur tout en travaillant sur la création d'un spa et l'amélioration des performances du logiciel à la fois du côté serveur et client.
Les applications à une seule page sont plus capables de diminuer le temps de chargement des pages et la quantité de transfert de données du serveur vers le client. Pourquoi ? Il y a plusieurs points de douleur tout en travaillant avec JavaScript Framework comme AngularJS, React, Vuejs, KO, Meteor, etc. dans une application MVC ASP.NET Core afin de créer une application à une seule page.
Téléchargez le fichier JS à partir d'ici et mettez-le dans le répertoire JS dans le dossier wwwroot
Remplacez le fichier "_viewstart.cshtml"
@{
if (Context.Request.Headers["X-Requested-With"] == "XMLHttpRequest")
{
Context.Response.Headers["Location"] = Microsoft.AspNetCore.Http.Extensions.UriHelper.GetDisplayUrl(Context.Request);
Context.Response.Headers["Cache-Control"] = "no-store";
}
else
{
Layout = "_Layout";
}
}
Ajoutez la référence du fichier ajxnetcore.js dans le fichier "_layout.cshtml"
<script src="~/js/ajxnetcore.js"></script>
Mettez le rendu () à l'intérieur d'une div avec une carte d'identité comme celle-ci
<div id="myid">@RenderBody()</div>
Finnaly ajoute les lignes suivantes juste avant la balise du corps de clôture
<script>
$(function() {
$('#myid').ajxnetcore();
})
</script>
Vous pouvez tester ce projet en téléchargeant le projet AJXnetcore.Demo

Le projet est sous licence MIT
Copyright (c) 2017 Amine Smahi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.