使用Server.Mappath()

编程入门 行业动态 更新时间:2024-10-25 02:25:14
本文介绍了使用Server.Mappath()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想使用使用Server.Mappath()方法IM为了映射虚拟目录 我创建它的物理路径。

I want to use Server.MapPath() method im order to map a virtual directory I created to its physical path.

的事情是,.NET环境不承认使用Server.Mappath()。

The thing is that the environment doesn't recognize Server.MapPath().

谷歌告诉我,我应该HttpContext.Current.Server使用的System.Web使用, 但HttpContext的是,尽管我使用的System.Web无法识别。 (而且我已经检查 - HttpContext的IS的System.Web中的类之一)

Google told me I'm supposed to use HttpContext.Current.Server using System.Web, but HttpContext isn't recognized in spite of me using System.Web. (And I've checked - HttpContext IS one of System.Web's classes)

帮助?

推荐答案

如果你有一个Web应用程序,您应具有自动引用 System.Web.dll中,你应该有机会获得 System.Web.HttpContext 类。请检查您是否不小心删除了参考。您将需要一个使用的System.Web; 语句访问的HttpContext 类,而无需指定完整的命名空间。

If you have a web application, you should automatically have a reference to System.Web.dll, and you should have access to the System.Web.HttpContext class. Check that you haven't accidentally removed the reference. You would need a using System.Web; statement to access the HttpContext class without specifying the complete namespace.

如果你没有一个Web应用程序,你将有一个referece添加到 System.Web.dll中来获得访问的HttpContext 类,但不会帮助你一点。由于你是不是在一个Web应用程序,没有HTTP上下文,也没有Web根文件夹中,这样你就不能使用MapPath方法。

If you don't have a web application you would have to add a referece to System.Web.dll to get access to the HttpContext class, but that would not help you a bit. As you are not in a web application, there is no HTTP context and there is no web root folder, so you can not use the MapPath method.

更多推荐

使用Server.Mappath()

本文发布于:2023-11-09 15:55:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1572791.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Server   Mappath

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!