server.mappath问题

时间:2011-02-12 20:36:31

标签: .net asp.net

我有这个包含路径的变量。

我希望使用此变量查看MapPath的结果,但是我收到此错误。有什么想法吗?

string FolderName = "Docs/1/1232"
'Server.MapPath(FolderName)' threw an exception of type 'System.Web.HttpException'

堆栈追踪:

  

at System.Web.Configuration.UserMapPath.GetPhysicalPathForPath(String path,VirtualDirectoryMapping mapping)      at System.Web.Configuration.UserMapPath.GetPathConfigFilename(String siteID,VirtualPath path,String& directory,String& baseName)      在System.Web.Configuration.UserMapPath.MapPath(String siteID,String path)      在System.Web.Hosting.HostingEnvironment.MapPathActual(VirtualPath virtualPath,Boolean permitNull)      在System.Web.Hosting.HostingEnvironment.MapPathInternal(VirtualPath virtualPath)      在System.Web.VirtualPath.MapPathInternal()      在System.Web.HttpRequest.MapPath(VirtualPath virtualPath,VirtualPath baseVirtualDir,Boolean allowCrossAppMapping)      在System.Web.HttpRequest.MapPath(VirtualPath virtualPath)      在System.Web.HttpServerUtility.MapPath(String path)      在C:\ Projects \ WebSites \ MyShul \ FileUpload.aspx.cs中的FileUpload.C​​reateFolder(String FolderName):第186行      在C:\ Projects \ WebSites \ MyShul \ FileUpload.aspx.cs中的FileUpload.UploadFile():第53行      at FileUpload.btnUpload_Click(Object sender,EventArgs e)位于c:\ Projects \ WebSites \ MyShul \ FileUpload.aspx.cs:第236行      在System.Web.UI.WebControls.Button.OnClick(EventArgs e)      在System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)      在System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)      在System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl,String eventArgument)      在System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)      在System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint)

1 个答案:

答案 0 :(得分:0)

您尝试映射的路径在虚拟目录中不存在。

确保使用正确的路径(例如, space 可能错误)。