In the code below, when I try to call the MapPath function inside Global.asax, a run-time error occurs with the following error message:
System.Web.HttpException (0 × 80004005): Request is not available in this context.
The faulty code is:
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
string path = HttpContext.Server.MapPath("~/assets/all.js")
// ... code
}
How to use a MapPath function in Global.asax?