Developer forum

Forum » Development » Loading control from generic handler

Loading control from generic handler


Reply
Here is the exception:

[NullReferenceException: Object reference not set to an instance of an object.]
   Dynamicweb.eCommerce.Common.Context.get_LanguageID() +25
   Dynamicweb.eCommerce.Products.Group.get_GroupByID(String groupID) +40
   Dynamicweb.eCommerce.Products.Group.GetGroupsByIDs(IEnumerable`1 groupIDs) +93

Here is the code I use:

RenderAjaxSearch.ashx.cs:

public void ProcessRequest(HttpContext context)
{
    context.Response.ContentType = "text/html";

    var productSearch = new UserControl().LoadControl("~/usercontrols/ProductSearch.ascx") as ProductSearch;
    productSearch.Initialize();
}

Here is the initialize method:

public void Initialize()
{
    var parentGroup = Group.GetGroupsByIDs(new List<string>
    {
        "SHOP2"
    }).Cast<Group>().FirstOrDefault();
}

Replies

 
Reply
Hello,

You need to allow read/write access to the Session State from your handler. In order to do so please implement the following interface in your handler class:

System.Web.SessionState.IRequiresSessionState

This interface has no methods so just add it to you class declaration.

- Pavel

 

You must be logged in to post in the forum