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. Server.MapPath() Problem!!!

Server.MapPath() Problem!!!

Scheduled Pinned Locked Moved ASP.NET
helpcssdatabasewpfwcf
4 Posts 2 Posters 0 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.
  • V Offline
    V Offline
    Varun Sareen
    wrote on last edited by
    #1

    Dear Friends, I want to open a file on the click of a link in the Grid named as VIEW. The path I am binding to is the local path i.e., ~/Documents/ScanDoc/[FileName] but when i am opening it on the local server; I am getting the error as follows:- File does not exist. System.Web.HttpException: File does not exist. at System.Web.StaticFileHandler.GetFileInfo(String virtualPathWithPathInfo, String physicalPath, HttpResponse response) at System.Web.StaticFileHandler.ProcessRequestInternal(HttpContext context) at System.Web.DefaultHttpHandler.BeginProcessRequest(HttpContext context, AsyncCallback callback, Object state) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
    But when I updated the PathColumn in database with this value:-"http://localhost:1383/~/Document/ScanDoc/\[FileName\]" which is actually being saved as "Documents/ScanDoc/[FileName]", the thing worked and i was able to see the file when i clicked on the link. Now my problem is that how could i bind "http://localhost:1383/~" path to "Documents/ScanDoc/[FileName]" which is being saved in the database. Thanks

    Varun Sareen (Dot Net Developer)

    H 1 Reply Last reply
    0
    • V Varun Sareen

      Dear Friends, I want to open a file on the click of a link in the Grid named as VIEW. The path I am binding to is the local path i.e., ~/Documents/ScanDoc/[FileName] but when i am opening it on the local server; I am getting the error as follows:- File does not exist. System.Web.HttpException: File does not exist. at System.Web.StaticFileHandler.GetFileInfo(String virtualPathWithPathInfo, String physicalPath, HttpResponse response) at System.Web.StaticFileHandler.ProcessRequestInternal(HttpContext context) at System.Web.DefaultHttpHandler.BeginProcessRequest(HttpContext context, AsyncCallback callback, Object state) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
      But when I updated the PathColumn in database with this value:-"http://localhost:1383/~/Document/ScanDoc/\[FileName\]" which is actually being saved as "Documents/ScanDoc/[FileName]", the thing worked and i was able to see the file when i clicked on the link. Now my problem is that how could i bind "http://localhost:1383/~" path to "Documents/ScanDoc/[FileName]" which is being saved in the database. Thanks

      Varun Sareen (Dot Net Developer)

      H Offline
      H Offline
      Hiren solanki
      wrote on last edited by
      #2

      Just grab the Url Authority like

      String UrlAuthority = String.Format("http://{0}",Request.Url.Authority);

      Now make a string of your static path

      String Path = "Documents/ScanDoc/[FileName]";

      Combine both for final Output

      String FullPath = Path.Combine(UrlAuthority,Path);

      And you're done.

      Regards, Hiren.

      My Recent Article: - Way to know which control have raised a postback
      My Recent Tip/Trick: - The ?? Operator.

      V 1 Reply Last reply
      0
      • H Hiren solanki

        Just grab the Url Authority like

        String UrlAuthority = String.Format("http://{0}",Request.Url.Authority);

        Now make a string of your static path

        String Path = "Documents/ScanDoc/[FileName]";

        Combine both for final Output

        String FullPath = Path.Combine(UrlAuthority,Path);

        And you're done.

        Regards, Hiren.

        My Recent Article: - Way to know which control have raised a postback
        My Recent Tip/Trick: - The ?? Operator.

        V Offline
        V Offline
        Varun Sareen
        wrote on last edited by
        #3

        Thanks Hiren, the thing you told worked

        Varun Sareen (Dot Net Developer)

        H 1 Reply Last reply
        0
        • V Varun Sareen

          Thanks Hiren, the thing you told worked

          Varun Sareen (Dot Net Developer)

          H Offline
          H Offline
          Hiren solanki
          wrote on last edited by
          #4

          Glad it helped you. You can always rate Answer if it helped you.

          Regards, Hiren.

          My Recent Article: - Way to know which control have raised a postback
          My Recent Tip/Trick: - The ?? Operator.

          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