0

I have created a class for the purpose of URL rewriting below is the code public class:

URLReWriter : IHttpModule
{
    private HttpApplication httpApp = null;

    /// <summary>
    /// Init Method implementation
    /// </summary>
    /// <param name="context"></param>
    void IHttpModule.Init(HttpApplication context)
    {
        context.BeginRequest += new EventHandler(context_BeginRequest);
        httpApp = context;
    }

    /// <summary>
    /// Dispose Method implementation
    /// </summary>
    void IHttpModule.Dispose()
    {

    }
}

In the Init function we are raising an event to call a function context.BeginRequest and implementing the interface IHttpModule.

I am implementing the interface IHttpModule, it has two methods Init and Dispose. Now I have aspx page and trying to call the Init function from URKReWriter class like this:

EnergyQuote.Framework.Utilities.URLReWriter obj
    = new EnergyQuote.Framework.Utilities.URLReWriter(); 

but it's not possible. Can we call the Init function from the aspx page?

BartoszKP
  • 34,786
  • 15
  • 102
  • 130
user2211918
  • 91
  • 3
  • 14

1 Answers1

1

The way you have implemented the interface (Explicit) in the class you need to cast the object to the interface to be able to call the functions:

var obj = (IHttpModule)new EnergyQuote.Framework.Utilities.URLReWriter(); 
obj.Init(context);
Community
  • 1
  • 1
Magnus
  • 45,362
  • 8
  • 80
  • 118