类文件中引用Server.MapPath的问题

oracleunix 2005-07-16 09:13:54
1:我想在一个类文件中引用Server.MapPath,导入名称空间
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls; 
还是不能引用

...全文
466 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
bmiracle 2005-07-16
  • 打赏
  • 举报
回复
System.Web.HttpContext.Current.Server.MapPath
写全了.
ccghghgj 2005-07-16
  • 打赏
  • 举报
回复
我一般处理:
在.aspx中把 server.mappath("/")作为参数传递到类中
这样类显得更加灵活
而在winform 中,就传递 application.startPath过去。

===============================
http://qqwwee.com/csdn.rar
CSDN小助手
Ivony 2005-07-16
  • 打赏
  • 举报
回复
必须是ASP.NET并且是收到HTTP请求的程序才能调用到。
ccghghgj 2005-07-16
  • 打赏
  • 举报
回复
类从page类继承。

===============================
http://qqwwee.com/csdn.rar
CSDN小助手
yb2008 2005-07-16
  • 打赏
  • 举报
回复
System.Web.HttpContext.Current.Server.MapPath("路径")

System.Web.HttpContext.Current.Response.Write("sdfdsfdfdsfsdfdfdf")
haonanernet 2005-07-16
  • 打赏
  • 举报
回复
Page.Server.MapPath();
gxboy 2005-07-16
  • 打赏
  • 举报
回复
Imports System.Web.HttpContext

Dim a As String = Current.Server.MapPath
oracleunix 2005-07-16
  • 打赏
  • 举报
回复
不行呀
noyester 2005-07-16
  • 打赏
  • 举报
回复
'属性:音乐服务器地址的Path
Public Shared ReadOnly Property RmHost() As String
Get
Return System.Configuration.ConfigurationSettings.AppSettings("RmHost")
End Get
End Property
zmhere 2005-07-16
  • 打赏
  • 举报
回复
request.server.mappath

62,025

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧