Accessing Server.Mappath from SoapExtension

Discussion in 'ASP .Net Web Services' started by PA, May 19, 2004.

  1. PA

    PA Guest

    I need to log all incoming soap messages in a file.

    I have follwing code in WriteInput routine of SoapExtension class

    Dim Server As System.Web.HttpServerUtility

    AppPath = Server.MapPath("App.ini")

    When I run the application, I get following error:

    Object reference not set to an instance of an object to server.MapPath line.

    can anyone tell me how to access/Set Server and it's properties?

    Or is there any other way to access a particular file?

    Thanks in advance.

    Pratibha
    PA, May 19, 2004
    #1
    1. Advertising

  2. you have not initialized your Server variable.

    you want

    Dim Server As System.Web.HttpServerUtility
    Server = System.Web.HttpContext.Current.Server

    A defensive coder may want to do this:

    if (System.Web.HttpContext.Current <> nothing ) then
    Server = System.Web.HttpContext.Current.Server
    ...


    (sorry I don't know VB syntax but you get the idea...)

    In other words, the System.Web.HttpContext.Current is a static member. If
    it is not set, then you have no HttpContext (which means your code is
    probably not running within ASP.NET) and if you have no context, then you
    cannot access the Server property of that context.

    -Dino


    "PA" <> wrote in message
    news:...
    > I need to log all incoming soap messages in a file.
    >
    > I have follwing code in WriteInput routine of SoapExtension class
    >
    > Dim Server As System.Web.HttpServerUtility
    >
    > AppPath = Server.MapPath("App.ini")
    >
    > When I run the application, I get following error:
    >
    > Object reference not set to an instance of an object to server.MapPath

    line.
    >
    > can anyone tell me how to access/Set Server and it's properties?
    >
    > Or is there any other way to access a particular file?
    >
    > Thanks in advance.
    >
    > Pratibha
    Dino Chiesa [Microsoft], May 19, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jon
    Replies:
    5
    Views:
    11,157
    Scott M.
    Jan 17, 2010
  2. =?Utf-8?B?dHBhcmtzNjk=?=

    server.mappath vs. request.mappath

    =?Utf-8?B?dHBhcmtzNjk=?=, Mar 10, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    1,147
    Juan T. Llibre
    Mar 11, 2007
  3. Replies:
    4
    Views:
    968
    Juan T. Llibre
    Oct 7, 2007
  4. Kenneth Baltrinic

    Accessing Server.MapPath from within Custom Controls Render() method?

    Kenneth Baltrinic, Oct 16, 2003, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    334
    Rajesh.V
    Oct 16, 2003
  5. Ajay Choudhary

    Accessing HttpApplicationState object from SoapExtension

    Ajay Choudhary, May 16, 2005, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    143
    Brock Allen
    May 18, 2005
Loading...

Share This Page