net core 3.1 知识累积
2021-03-13 05:29
标签:aaa www star wro text direct cto result factory 模块 --> AspNetCoreModuleV2 为什么不发布就不能部署? -- 直接指向项目,会失败 1.在bin目录直接运行 样式问题: 新建一个 Filter\CustomExceptionFilterAttribute.cs 在有错的地方就会执行 Startup.cs HomeController.cs net core 3.1 知识累积 标签:aaa www star wro text direct cto result factory 原文地址:https://www.cnblogs.com/tangge/p/12822173.html部署发布
IIS发布篇
命令行篇
dotnet Study.NetCore31.practical.dll --urls=http://*:3001
//1.把wwwroot拷贝过去
//2.添加默认路径
app.UseStaticFiles( new StaticFileOptions()
{
FileProvider =new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(),"wwwroot"))
});
AOP注册
public class CustomExceptionFilterAttribute : ExceptionFilterAttribute
{
public override void OnException(ExceptionContext context)
{
Console.WriteLine("aaaa");
//base.OnException(context);
}
}
1.全局注册
services.AddControllersWithViews(option =>
{
//全局注册filter
option.Filters.Add(typeof(CustomExceptionFilterAttribute));
});
2.ServiceFilter
services.AddTransient(typeof(CustomExceptionFilterAttribute));
//放在控制器
[ServiceFilter(typeof(CustomExceptionFilterAttribute))]
public class HomeController : Controller
{
...
public IActionResult Privacy()
{
throw new Exception("12");
return View();
}
}
3.TypeFilter
4.IFilterFactory
StartUp 启动顺序
上一篇:JsChart组件使用
下一篇:HTTP 状态