Welcome to Julian Kuiters Friday, October 19 2018 @ 09:12 AM AEDT

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

.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