How can I use Server.MapPath() from global.asax?

二次信任 提交于 2019-11-29 18:54:11

You could try System.Web.Hosting.HostingEnvironment.MapPath().

No HttpContext required.

Kiran Banda

Use AppDomain.CurrentDomain.BaseDirectory because Context might return null !!

When in Global.asax, use the context object:

context.Server.mappath()

Context lets you access also the session collection, the request object, the response object. Very useful when you want to log errors, for example

You could try HttpContext.Current.Server.MapPath("/") - That's how I have referenced it before in classes.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!