locked
Server.Mappath returns C:\ ..... RRS feed

  • Question

  • User-1280298123 posted
    Hi, Don't know weather this problem is specific for Mobile Applications. But since this problem only occurs in my asp.net Mobile Web Application(MobileApplication), i direct my question to this forum. I have a virtual catalogue (Images) mapped to catalouge on another server (\\testserver\images_public) I use: Server.Mappath("Images") ..to find out the path to the catalogue and then add the imagename (myImage.jpg) Ex: Dim path as String path= Server.MapPath("Images") & "\" & myImage.jpg I expect path to hold: "\testserver\images_public\myImage.jpg" Instead it gives me: "c:\inetpub\wwwroot\MobileApplication\Images\myImage.jpg" Does anyone know why I don't get the correct path in return? And even more important, -what to do to get the correct path in return. Thank you all! */Tindra*
    Friday, March 4, 2005 10:03 AM

All replies

  • User-1804824805 posted
    What are you trying to do? MapPath takes a virtual path, and returns the actual file path. If you want to refer to the file in an image tag/etc., just use "Images/myImage.jpg"
    Friday, March 4, 2005 4:29 PM
  • User-1280298123 posted
    Hello Douglas, Thank's for trying to help me out. I need to download the file, -using the virtual catalogue, and resize it. The image is to large in its origin version. */Tindra*
    Sunday, March 6, 2005 2:24 PM
  • User-1804824805 posted
    OK. Give the EXACT function you are trying to use. Give the EXACT path of the real file, as well as the EXACT path for the current project and perhaps we can help.
    Sunday, March 6, 2005 3:30 PM
  • User-1280298123 posted
    Hi again, Here are the function used. 'CamPics' is the name of the virtual catalogue mapping to the share on antoher server. The path to the share is:"\\TestServer1\images_public". Private Sub ViewCamera() Try Dim cam As New Camera ---->Dim s As String = cam.GetCameraImage(m_FeatureId, Server.MapPath("CamPics"), Session.SessionID.ToString, GetRequestScreenWidth) <---------------- AddImageToPanel("CamPics/" & s) pnlCameraImage.Visible = True Catch ex As Exception ErrorManager.ManageError(ex, Server.MapPath("error.log")) Response.Write("Ett fel inträffade.") End Try End Sub Thank's! */Tindra*
    Monday, March 7, 2005 4:13 AM
  • User-1804824805 posted
    OK. You cannot use MapPath to get a network share. I would simply configure the network share in Web.Config appSettings section. MapPath() will not do it. You will also have some security issues getting at the remote server, as by default, ASPNET user will be local to the Web server and not have access to the share on another server.
    Monday, March 7, 2005 9:10 AM
  • User-1280298123 posted
    OK, thank's a lot. It seems to work fine using the solution You suggested. I have solved the security issue by using 'identity impersonate' in web.config. Many thank's :) */Tindra*
    Monday, March 7, 2005 9:34 AM
  • User-95561675 posted

    I'm trying to solve almost the same problem.  Can either of you give an example of an appropriate appsettings key/value pair for a UNC connection to another server?

    Wednesday, December 14, 2005 5:35 PM