ajxnetcore
1.0.0

它是將ASP.NET Core應用程序變成單頁應用程序的創新方法,其目標是在創建水療中心並在服務器和客戶端上增強軟件性能時減少開發人員的努力。
單頁應用程序更有能力減少頁面的負載時間以及從服務器到客戶端的數據傳輸量。為什麼 ?在ASP.NET Core MVC應用程序中使用JavaScript框架(例如AngularJS,React,Vuejs,敲除,流星等)時,有幾個疼痛點,以創建單頁應用程序。
從此處下載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>
將Renderbody()放在帶有ID的DIV中
<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.