Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Problem with Server.MapPath() in ASP.NET 2.0

Problem with Server.MapPath() in ASP.NET 2.0

Scheduled Pinned Locked Moved ASP.NET
helpcsharpasp-netvisual-studiodesign
3 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tantiboh
    wrote on last edited by
    #1

    I built a project in VS 2003 under .NET 1.1 with the following line: ... = Server.MapPath("../includes/navigation_bar.inc"); To be clear, I was referring to the includes directory, located in the directory above my application's root directory. Worked great, that version is still live and running fine. I'm trying to upgrade the program to ASP 2.0 now in VS 2005. The same line gives the following error: System.InvalidOperationException was unhandled by user code Message="Failed to map the path '/includes/navigation_bar.inc'." I've tried for several hours to find a workaround or other solution, but to no avail. Unfortunately, many pages on the website refer to that file, so moving it is not an option. My hunch is that ASP is no longer allowing referrals to files on the server outside of the application's directory, but the purpose behind such a change is puzzling. Any ideas? Anybody know why this is a problem now when it wasn't under .NET 1.1? I appreciate your help! _________________________________________ For information, here are the full details of the error: System.InvalidOperationException was unhandled by user code Message="Failed to map the path '/includes/navigation_bar.inc'." Source="System.Web" StackTrace: at System.Web.Hosting.HostingEnvironment.MapPathActual(VirtualPath virtualPath, Boolean permitNull) at System.Web.Hosting.HostingEnvironment.MapPathInternal(VirtualPath virtualPath) at System.Web.VirtualPath.MapPathInternal() at System.Web.HttpRequest.MapPath(VirtualPath virtualPath, VirtualPath baseVirtualDir, Boolean allowCrossAppMapping) at System.Web.HttpRequest.MapPath(VirtualPath virtualPath) at System.Web.HttpRequest.MapPath(String virtualPath) at Applicators.referrals.Page_Load(Object sender, EventArgs e) in c:\Inetpub\wwwroot\Applicators\referrals.aspx.cs:line 57 at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

    M 1 Reply Last reply
    0
    • T tantiboh

      I built a project in VS 2003 under .NET 1.1 with the following line: ... = Server.MapPath("../includes/navigation_bar.inc"); To be clear, I was referring to the includes directory, located in the directory above my application's root directory. Worked great, that version is still live and running fine. I'm trying to upgrade the program to ASP 2.0 now in VS 2005. The same line gives the following error: System.InvalidOperationException was unhandled by user code Message="Failed to map the path '/includes/navigation_bar.inc'." I've tried for several hours to find a workaround or other solution, but to no avail. Unfortunately, many pages on the website refer to that file, so moving it is not an option. My hunch is that ASP is no longer allowing referrals to files on the server outside of the application's directory, but the purpose behind such a change is puzzling. Any ideas? Anybody know why this is a problem now when it wasn't under .NET 1.1? I appreciate your help! _________________________________________ For information, here are the full details of the error: System.InvalidOperationException was unhandled by user code Message="Failed to map the path '/includes/navigation_bar.inc'." Source="System.Web" StackTrace: at System.Web.Hosting.HostingEnvironment.MapPathActual(VirtualPath virtualPath, Boolean permitNull) at System.Web.Hosting.HostingEnvironment.MapPathInternal(VirtualPath virtualPath) at System.Web.VirtualPath.MapPathInternal() at System.Web.HttpRequest.MapPath(VirtualPath virtualPath, VirtualPath baseVirtualDir, Boolean allowCrossAppMapping) at System.Web.HttpRequest.MapPath(VirtualPath virtualPath) at System.Web.HttpRequest.MapPath(String virtualPath) at Applicators.referrals.Page_Load(Object sender, EventArgs e) in c:\Inetpub\wwwroot\Applicators\referrals.aspx.cs:line 57 at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      Hi there, Are using the File System for your website in the VS 2005? If so, when you debug your application, the VS uses its built-in ASP.NET development server and it can cause the error when you go out of the application boudanry. In this case, you might try to run your application using the IIS server, it should be working.

      T 1 Reply Last reply
      0
      • M minhpc_bk

        Hi there, Are using the File System for your website in the VS 2005? If so, when you debug your application, the VS uses its built-in ASP.NET development server and it can cause the error when you go out of the application boudanry. In this case, you might try to run your application using the IIS server, it should be working.

        T Offline
        T Offline
        tantiboh
        wrote on last edited by
        #3

        Thanks, that was the tip I needed.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups