First look at the sample controller code. There you'll find two statements which are repetitive-
public class DashboardController : Controller
{
//the following line is repetitive for every controller.
String ConnectionString = WebConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString;
public ActionResult Index()
{
try
{
//codes
}
catch (Exception Ex)
{
//The following line is repetitive for every action method.
var path = HttpContext.Server.MapPath("~/App_Data");
ExceptionLog.Create(Ex, path);
}
return View("AdminDashboard");
}
}
I would like to avoid such repetition. Is there any way to do it which can work for the entire application as global variable?