Welcome to Julian Kuiters Thursday, August 16 2018 @ 03:02 PM AEST

ASP.Net - Server operation is not available in this context - Using Server.MapPath in Global.asax

  • Contributed by:
.NET Programming

If you try to use the Server.MapPath() function in your global.asax file for ASP.Net you are likely to encounter this error:

Server operation is not available in this context

To use Server.MapPath() in global.asax instead use:

System.Web.Hosting.HostingEnvironment.MapPath()

More details about System.Web.Hosting.HostingEnvironment.MapPath() are available on MSDN