IHttpModule : Init : getting Server.MapPath

  • Thread starter Nicholas Irving
  • Start date
N

Nicholas Irving

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.geolocate.locate cl = null;

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

// In the Init function, register for HttpApplication
// events by adding your handlers.
public void Init(HttpApplication application)
{
application.PreRequestHandlerExecute += (new
EventHandler(this.doFilterStart));
Blah blah = new blan(application.Server.MapPath("/"));
}

// Your BeginRequest event handler.
private void doFilterStart(Object 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 = (HttpApplication)source;
HttpContext context = application.Context;
if (null == (Country) context.Session["CountryInfo"])
{
//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
(e-mail address removed)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top