是否有更好的方法来捕获异常?我好像在复制很多代码.基本上在每个控制器中我都有一个catch语句来执行此操作:
try
{
Do something that might throw exceptions.
}
catch (exception ex)
{
Open database connection
Save exception details.
If connection cannot be made to the database save exception in a text file.
}
Run Code Online (Sandbox Code Playgroud)
我在每个控制器中有4个控制器和大约5-6个动作方法,这是很多代码重复.如何减少上面try catch语句中的行数?