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. Database & SysAdmin
  3. Database
  4. Server Object - Where to find the Dll ?

Server Object - Where to find the Dll ?

Scheduled Pinned Locked Moved Database
sysadminquestion
8 Posts 3 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
    Vector7
    wrote on last edited by
    #1

    Hello, I want to use the command Server.MapPath and need the Server object. Where I can found it for reference ?

    H 1 Reply Last reply
    0
    • V Vector7

      Hello, I want to use the command Server.MapPath and need the Server object. Where I can found it for reference ?

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      The Server property is an intrinsic object accessible from within ASP.NET. You cannot simply use Server.MapPath (which is actually HttpServerUtility.MapPath) because 1) it's an instance method and you cannot instantiate the HttpServerUtility class yourself, and 2) it only works with a given virtual path because it needs to map a virtual path to a physical path. This is specific to both the virtual host and the virtual directory. Even on two different virtual hosts, a virtual directory will map differently to the same physical directory. For future reference, if you have a question about what assembly a class (not object, which is an instance of a class) is defined in, you can view the bottom of the class documentation topic in the .NET Framework SDK that states what namespace and in what assembly the class (or any Type) is defined. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles] [My Blog]

      V 1 Reply Last reply
      0
      • H Heath Stewart

        The Server property is an intrinsic object accessible from within ASP.NET. You cannot simply use Server.MapPath (which is actually HttpServerUtility.MapPath) because 1) it's an instance method and you cannot instantiate the HttpServerUtility class yourself, and 2) it only works with a given virtual path because it needs to map a virtual path to a physical path. This is specific to both the virtual host and the virtual directory. Even on two different virtual hosts, a virtual directory will map differently to the same physical directory. For future reference, if you have a question about what assembly a class (not object, which is an instance of a class) is defined in, you can view the bottom of the class documentation topic in the .NET Framework SDK that states what namespace and in what assembly the class (or any Type) is defined. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles] [My Blog]

        V Offline
        V Offline
        Vector7
        wrote on last edited by
        #3

        Hello, thx for response. Yes I am working on an ASP.NET project and need the MapPath Method. But if I cannot instantiate it, i have no possibilities accessing it ?

        C 1 Reply Last reply
        0
        • V Vector7

          Hello, thx for response. Yes I am working on an ASP.NET project and need the MapPath Method. But if I cannot instantiate it, i have no possibilities accessing it ?

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #4

          Vector7 wrote: Yes I am working on an ASP.NET project and need the MapPath Method. But if I cannot instantiate it, i have no possibilities accessing it ? Did you read what Heath said? You cannot instantiate it. It is created by the framework for you. In your page class there is a property called Server[^] which exposes a pre-existing instance of the class which you can use.


          Do you want to know more? WDevs.com - Member's Software Directories, Blogs, FTP, Mail and Forums

          V 1 Reply Last reply
          0
          • C Colin Angus Mackay

            Vector7 wrote: Yes I am working on an ASP.NET project and need the MapPath Method. But if I cannot instantiate it, i have no possibilities accessing it ? Did you read what Heath said? You cannot instantiate it. It is created by the framework for you. In your page class there is a property called Server[^] which exposes a pre-existing instance of the class which you can use.


            Do you want to know more? WDevs.com - Member's Software Directories, Blogs, FTP, Mail and Forums

            V Offline
            V Offline
            Vector7
            wrote on last edited by
            #5

            I have read it, but still not the correct hint. This is what I've looked for : HttpContext.Current.Server.MapPath :) Because I didn't found the Server object, I thought I need an explicit IIS dll. But now I found this in the web by chance ( all other places show System.MapPath instead the right ASP.NET Version ).

            H 1 Reply Last reply
            0
            • V Vector7

              I have read it, but still not the correct hint. This is what I've looked for : HttpContext.Current.Server.MapPath :) Because I didn't found the Server object, I thought I need an explicit IIS dll. But now I found this in the web by chance ( all other places show System.MapPath instead the right ASP.NET Version ).

              H Offline
              H Offline
              Heath Stewart
              wrote on last edited by
              #6

              You can also access the Server property from the Page class (or rather the instance of the Page for your code, if you're running within a .aspx for example). Excuse me for wondering why you're trying to access the Server property when you posted in the ADO/ADO.NET forum. Next time please use the appropriate forum, i.e. the ASP.NET forum. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles] [My Blog]

              V 1 Reply Last reply
              0
              • H Heath Stewart

                You can also access the Server property from the Page class (or rather the instance of the Page for your code, if you're running within a .aspx for example). Excuse me for wondering why you're trying to access the Server property when you posted in the ADO/ADO.NET forum. Next time please use the appropriate forum, i.e. the ASP.NET forum. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles] [My Blog]

                V Offline
                V Offline
                Vector7
                wrote on last edited by
                #7

                Excuse me for wondering why you're trying to access the Server property when you posted in the ADO/ADO.NET forum. Next time please use the appropriate forum, i.e. the ASP.NET forum. Because I am developing a DB Application, where I need this in the connectionstring.

                H 1 Reply Last reply
                0
                • V Vector7

                  Excuse me for wondering why you're trying to access the Server property when you posted in the ADO/ADO.NET forum. Next time please use the appropriate forum, i.e. the ASP.NET forum. Because I am developing a DB Application, where I need this in the connectionstring.

                  H Offline
                  H Offline
                  Heath Stewart
                  wrote on last edited by
                  #8

                  It's still a question about ASP.NET. If you had a question about how to do a particular operation in C# you'd ask in the C# forum. The context of the application isn't as important as the context of the question. We don't know what you're writing, but if you ask in the right forum you'll get a more appropriate response. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles] [My Blog]

                  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