This article is only to make friends who encounter similar problems less detours
ASP.
I call a custom class with a CS file on a page, and the custom class calls the System.Web.HttpContext.Current.Server.MapPath method, which produces an error message that does not set the object reference to an instance of the object. Originally thought to be a custom class calling another custom class question, searched for half a day without finding the answer
So want to call System.Web.HttpContext.Current.Server.MapPath directly with the custom class, found still not, but with inherited System.Web.UI.Page CS file to call the class System.Web.HttpContex T.current.server.mappath will not go wrong, finally found
System.Web.HttpContext.Current.Server.MapPath
(System.Web.HttpContext.Current.Request.MapPath is also) to be called by the ASPX, even if the class inherits the System.Web.UI.Page call will also error
DLL file to get the current path you have to find another way.
System.AppDomain.CurrentDomain.BaseDirectory can be used, effects such as D:\myweb\
System.AppDomain.CurrentDomain.BaseDirectory is to find the base directory.
When I use it, as shown in
Server.MapPath occurrences of object references not set to an object