好男当家演员表,龙域bt,遗爱记 蓝白色
1、发布的时候把视图cshtml文件也编译为dll了,如何控制不编译视图?
编辑功能文件(xx.csproj),加入一个选项:
<propertygroup>
<targetframework>netcoreapp2.1</targetframework>
<mvcrazorcompileonpublish>false</mvcrazorcompileonpublish>
</propertygroup>
2、网站里面有 .less等静态资源文件 dotnet core 默认是不允许访问的,如何解决呢
在startup的configure方法中加入文件扩展的提供程序,例如:
var provider = new fileextensioncontenttypeprovider(); provider.mappings[".less"] = "text/css"; app.usestaticfiles(new staticfileoptions() { contenttypeprovider = provider });
3、多cookie登录如何配置呢?
在startup的 configureservices方法中加入以下代码:
//添加认证cookie信息 services.addauthentication(cookieauthenticationdefaults.authenticationscheme) .addcookie(cookieauthenticationdefaults.authenticationscheme + "_client", options => { options.loginpath = new pathstring("/login"); options.accessdeniedpath = new pathstring("/tool"); }) .addcookie(cookieauthenticationdefaults.authenticationscheme, options => { options.loginpath = new pathstring("/admin/login"); options.accessdeniedpath = new pathstring("/admin"); });
注意主要使用authenticationscheme 区分不同cookie的,所有在登录的时候也要用相应的 authenticationscheme,例如:
var identity = new claimsidentity(cookieauthenticationdefaults.authenticationscheme+"_client"); identity.addclaim(new claim(claimtypes.sid, userentity.loginname)); identity.addclaim(new claim(claimtypes.name, userentity.loginname)); await httpcontext.signinasync(cookieauthenticationdefaults.authenticationscheme+"_client", new claimsprincipal(identity));
4、多个areas的站点 发布后在window下可以而linux不行,找不到区域下的视图
一般是区域的名称设置的大小写的问题,我遇到的问题是 我的程序里面区域是这样定义的 [area("admin")],而我发布后区域视图文件夹是 admin 所以找不到
5、dotnet core 命令行启动的时候如何用默认的端或者指定端口呢?
dotnet xx.dll urls="http://*:80"
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Net Core Web Api项目与在NginX下发布的方法
asp.net core3.1 引用的元包dll版本兼容性问题解决方案
IdentityServer4实现.Net Core API接口权限认证(快速入门)
ASP.NET Core MVC通过IViewLocationExpander扩展视图搜索路径的实现
网友评论