During the last four years as a developer at BlueBolt Solutions, I occasionally need to create a DotNetNuke module that would need to load some data though an AJAX call to the server, for example, if a module requires internal search or a module that allows users to load comments for a specific comment thread. There are different approaches to perform this AJAX request and I wanted to share my observations thus far.
Getting the current user info:
public class HandlerForSomething : IHttpHandler
public void ProcessRequest(HttpContext context)
context.Response.ContentType = "text/plain";
UserInfo user = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo();
After getting the user we can perform different checks on that user. Whether (s)he is in a certain role or even whether (s)he is logged in:
if (user.IsInRole("Administrators") || user.IsSuperUser)
//Load some data here…
Getting the current portal info:
PortalSettings ps = (PortalSettings)context.Items["PortalSettings"];
if (ps != null)
//Here we can use ps.PortalId to load data for the current portal only
The PortalSettings object is stored in HTTPContext before your handler is processed.