I am able to get the CurrentSideId, I can say anywhere through the application. I have a class called MainClass. It has static CurrentSideId
property. MainClass.CurrentSiteId
returns the SiteId
requested.
public class MainClass{
public static int CurrentSiteId
{
get { return HttpContext.Current.Request.RequestContext.RouteData.Values["CurrentSiteId"].To<int>(); }
set {..}
}
}
But, when it comes to ProcessRequest
method of the HttpHandler
, CurrentSiteId
throws an exception of type System.InvalidCastException
: Null object cannot be converted to a value type.
public class MyRouteHandler : MvcRouteHandler
{
protected override IHttpHandler GetHttpHandler(RequestContext requestContext)
{
return new MyHttpHandler();
}
}
public class MyHttpHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
var siteId = MainClass.CurrentSiteId;
}
}
What would be the resolution?