Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesUserId with DnnApiController is -1 for child sites?UserId with DnnApiController is -1 for child sites?
Previous
 
Next
New Post
7/5/2016 4:27 PM
 

Hi,

 I'm trying to get the current user and the current portal id with DnnApiController, but it works only for the main site.

How I tested:
- new install of DNN 8.0., at http://localhost/dnn8/ >>> create "user1" in main site
- created one child site (http://localhost/dnn8/site2) >>> create "user2"

The code I used (and other methods, similar to it):

[HttpGet]
[AllowAnonymous]
public int GetUserId()
{
return UserController.Instance.GetCurrentUserInfo().UserID;
//return base.UserInfo.UserID;
}

- main site: authenticate with "user1" and the call, directly in the browser: http://localhost/dnn8/DesktopModules/AdmitereDNNAPI/API/AdmitereDNNAPI/GetUserId >>it works, because it returns an integer

- child site: authenticate with "user2" (in private / incognito..) and and the call, directly in the browser, is a second tab: http://localhost/dnn8/DesktopModules/AdmitereDNNAPI/API/AdmitereDNNAPI/GetUserId >> it doesn't work as it always returns -1  AND the user is disconnected from the first tab (if I try to navigate to another page, the user in the upper-right-corner is no longer displayed)

If I try to get the portalId, it returns 0 for both the main and child site.

I've tried http://jimfrenette.com/2013/07/dnn-windows-client/ ==> <modules runAllManagedModulesForAllRequests="true"> and it doesn't work

Also, from http://www.dnnsoftware.com/community-blog/cid/144400/webapi-tips I've tried to use [DnnAuthorize], but it doesn't work either - the user is disconnected in the first tab, and the message from the request in the second tab is Authorization has been denied for this request.

Help, please

Catalin

 

 

 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesUserId with DnnApiController is -1 for child sites?UserId with DnnApiController is -1 for child sites?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out