ajxnetcore
1.0.0

ASP.NETコアアプリケーションをシングルページアプリケーションに変える革新的な方法である目標は、SPAの作成に取り組み、サーバーとクライアント側の両方でソフトウェアパフォーマンスを強化しながら、開発者の努力を減らすことです。
シングルページアプリケーションは、ページの読み込み時間とサーバーからクライアントへのデータ転送の量を短縮することができます。なぜ ? Angularjs、React、Vuejs、ノックアウト、MeteorなどのJavaScriptフレームワークを使用して、単一ページアプリケーションを作成するためにASP.NETコアMVCアプリケーションなどの問題のあるポイントがいくつかあります。
ここからJSファイルをダウンロードし、wwwrootフォルダーの下のJSディレクトリに配置します
「_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";
}
}
"_layout.cshtml"ファイルにajxnetcore.jsファイルの参照を追加します
<script src="~/js/ajxnetcore.js"></script>
このようなIDを持つdiv内にrenderbody()を配置します
<div id="myid">@RenderBody()</div>
finnaly閉じるボディタグのためだけに次の行を追加します
<script>
$(function() {
$('#myid').ajxnetcore();
})
</script>
ajxnetcore.demoプロジェクトをダウンロードして、このプロジェクトをテストできます

プロジェクトは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.