3

I'm trying to get the current logged in user once they've reached my app hosted on our DotNetNuke page. The app is built in React.JS, and I'm rending it inside the HTML module. When the user reaches the app, I'm doing a ComponentDidMount method call, and initiating a AJAX request to my .ascx file to get the current user. (ComponentDidMount gets invoked automatically only once, when the app is loaded -- For all the .NET people reading this). Once in the ASCX file, I'm executing the code below, but only get the output of "user ". Am I supposed to call a class to use this token in another file ? What can I do in my code below to get the current user logged in to the site (DNN does not use session variables sadly, only tokens).

.ascx Code:

<%   
    Response.Write("user " & [User:UserName])    
%>
VDWWD
  • 35,079
  • 22
  • 62
  • 79
Justin E. Samuels
  • 867
  • 10
  • 28

1 Answers1

5

I don't understand your design, but I can answer your question. The square bracket tokens are replacements that are done within the HTML module content. You can't use them in server-side .ascx. You would need to call the a core DNN API method to get the user from the server-side .ascx code:

<% 
    Response.Write("user " & DotNetNuke.Entities.Users.UserController.Instance.GetCurrentUserInfo().Username);    
%>  
VDWWD
  • 35,079
  • 22
  • 62
  • 79
Fix It Scotty
  • 2,852
  • 11
  • 12