
É um método inovador para transformar um aplicativo ASP.NET Core em um aplicativo de página única, o objetivo é reduzir o esforço do desenvolvedor enquanto trabalha na criação de um spa e aprimorando o desempenho do software no lado do servidor e do cliente.
Os aplicativos de página única são mais capazes de diminuir o tempo de carregamento das páginas e a quantidade de transferência de dados do servidor para o cliente. Por que ? Existem vários pontos problemáticos enquanto trabalham com a estrutura JavaScript, como AngularJS, React, Vuejs, Knockout, Meteor etc. em um aplicativo MVC do ASP.NET Core para criar um aplicativo de página única.
Faça o download do arquivo JS daqui e coloque -o no diretório JS na pasta wwwroot
Substitua o arquivo "_viewstart.cshtml" com
@{
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";
}
}
Adicione a referência do arquivo AjxnetCore.js no arquivo "_layout.cshtml"
<script src="~/js/ajxnetcore.js"></script>
Coloque o renderbody () dentro de uma div com um id como este
<div id="myid">@RenderBody()</div>
Finnaly Adicione as seguintes linhas apenas para a etiqueta corporal de fechamento
<script>
$(function() {
$('#myid').ajxnetcore();
})
</script>
Você pode testar este projeto baixando o projeto AJXNETCORE.DEMO

O projeto está sob licença do 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.