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