web开发中,为什么在类中没有Server对象呀
web开发中,
为什么在类中没有Server对象呀
我想封装一个FileUpload对象的方法在里边,需要获取服务器的路径,
因为写得太死了不好,也容易出错,
有没有别的变通的办法,
[解决办法]
哪里没有 Server 对象? asp.net 的project 肯定有,但名字不叫Server ,类型改成了 System.Web.HttpServerUtility
[解决办法]
A:HttpContext.Server.MapPath(HttpContext.Request.ApplicationPath);
B:直接在webconfig里写个参数.以后要修改就直接改webconfig
[解决办法]
1.确定项目里添加了 System.Web.dll 的引用
2.使用 System.Web.HttpContext.Current.Server