IHttpModule : Init : getting Server.MapPath

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nicholas Irving

    #1

    IHttpModule : Init : getting Server.MapPath

    Hi all,
    I am having an issue with one of my HttpModules where I cannot get the
    application path on Init.
    What I would like to do is to the following

    public class wherefrom : IHttpModule
    {
    private com.nirving.geo locate.locate cl = null;

    public String ModuleName
    {
    get { return "wherefrom" ; }
    }

    // In the Init function, register for HttpApplication
    // events by adding your handlers.
    public void Init(HttpApplic ation application)
    {
    application.Pre RequestHandlerE xecute += (new
    EventHandler(th is.doFilterStar t));
    Blah blah = new blan(applicatio n.Server.MapPat h("/"));
    }

    // Your BeginRequest event handler.
    private void doFilterStart(O bject source, EventArgs e)
    {
    //Okay we need to check to see if the user has a session open.
    // If not we create the session with the correct country information.
    HttpApplication application = (HttpApplicatio n)source;
    HttpContext context = application.Con text;
    if (null == (Country) context.Session["CountryInf o"])
    {
    //Do something
    ;
    }
    }

    public void Dispose()
    {
    }

    If I do this I get an error

    Server operation is not available in this context.
    So how can I get it to give the initial startup directory for my Init?

    Nicholas Irving
    nirving@darkedg es.com



Working...