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.