VUE版关闭调试模式:appsettings文件中有一个IsQuickDebug属性,默认是true,当IsQuickDebug为true的时候框架处于调试模式,框架会反射你所有controller的方法并列在左边菜单中,并跳过所有权限验证,方便你进行调试。当IsQuickDebug为false的时候,框架才会读取你配置的菜单并进行权限验证。所以当你发布生产环境的时候,请把IsQuickDebug改为false。
前端关闭调试模式的方法官方文档没有介绍
方法为:打开前端页面配置 \ClientApp\src\config\index.ts
development: false
原因:报文头设置成了accept: application/json
解决方法:accept: text/plain
创建一个vm,用vm的DC.Set<>()来查询数据库的数据。
var listVM = CreateVM();
var LicObjs = listVM.DC.Set().Where.....
服务器启动IIS,设定文件夹的权限,部署数据库,都简单,不细说
IIS支持 .net core 3.1:
下载ASP.netCore Runtime 3.1 X86或X64 和Hosting Bundle(用于加载模块)
https://dotnet.microsoft.com/download/dotnet-core/3.1
前后端分离,前端页面的配置:
在Program.cs的webBuilder.Configure写入下面的配置
x.UseSpaStaticFiles();
x.UseFrameworkService();
if (env.IsDevelopment() == false)
{
DefaultFilesOptions dfo = new DefaultFilesOptions();
dfo.DefaultFileNames.Clear();
dfo.DefaultFileNames.Add("index.html");
x.UseDefaultFiles(dfo);
StaticFileOptions sfo = new StaticFileOptions();
var pfp = System.IO.Path.Combine(env.ContentRootPath, "wwwroot/");
sfo.FileProvider = new Microsoft.Extensions.FileProviders.PhysicalFileProvider(pfp);
x.UseStaticFiles(sfo);
}
将生成的前端页面复制到wwwroot文件夹下面,就可以访问了。
https://docs.microsoft.com/zh-cn/aspnet/core/test/troubleshoot-azure-iis?view=aspnetcore-3.1
生成32位部署到win7 64位
发布时选了独立,解决方法将应用作为依赖框架的部署进行发布
参考 https://www.cnblogs.com/EminemJK/p/10830505.html
方法一:应用池高级配置 - 启动32位应用程序 - 设置为True
方法二:删掉 web.config中的 hostingModel="InProcess"
关于HostingModel的两种模式:
http://www.binaryintellect.net/articles/bb086279-ed2a-4628-85f2-7e91125fbe57.aspx
日志:
Failed to load the dll from [C:\Program Files (x86)\dotnet\host\fxr\3.1.0\hostfxr.dll], HRESULT: 0x80070057
The library hostfxr.dll was found, but loading it from C:\Program Files (x86)\dotnet\host\fxr\3.1.0\hostfxr.dll failed
- Installing .NET Core prerequisites might help resolve this problem.
https://go.microsoft.com/fwlink/?linkid=798306
Failed to load the dll from [C:\Program Files (x86)\dotnet\host\fxr\3.1.0\hostfxr.dll], HRESULT: 0x80070057
The library hostfxr.dll was found, but loading it from C:\Program Files (x86)\dotnet\host\fxr\3.1.0\hostfxr.dll failed
- Installing .NET Core prerequisites might help resolve this problem.
https://go.microsoft.com/fwlink/?linkid=798306
安装KB2533623补丁
遇到迁移失败
Could not load assembly 'XXX'. Ensure it is referenced by the startup project 'XXX'.
项目生成为32位,改为X64可以正常迁移
Model里添加属性,EF数据迁移或手动给数据库添加字段
添加数据:
修改Controller
修改前端 进行添加操作时添加字段 (添加特性[DataMember(Name="Description", EmitDefaultValue=false)] 使其可以被Json序列化)
查询:
ListVM中GetSearchQuery 生成对象时添加查询字段
InitGridHeader 添加字段
前台查询出的列表增加显示字段
Swagger提示 the method post on path is registered multiple times
解决方法:
特性标记加参数 [HttpPost("p2")]