I have written a web service in an asmx file (stored under Umbraco\WebServices) and use methods I have in a class in a separate cs file.
I would like to access the Umbraco loggedin user id - so in my calls I am
using Umbraco.Core.Security;
using Umbraco.Core.Models.Membership;
...
var authenticationTicket = new HttpContextWrapper(HttpContext.Current).GetUmbracoAuthTicket();
IUser user = null;
if (authenticationTicket != null)
{
user = UmbracoContext.Current.Application.Services.UserService.GetByUsername(authenticationTicket.Name);
}
else
{
// not logged into backoffice
}
// use it if not null
var lUserId = "";
if(user != null)
{
lUserId = user.Id.ToString();
}
This is actually returning the logged in user, which suggests that the web service is part of the main application session and has access to HttpContext.
My question is - is this reliable, ie is the web service always going to be able to query HttpContext, or is this going to be flaky?
UserId in web service?
I have written a web service in an asmx file (stored under Umbraco\WebServices) and use methods I have in a class in a separate cs file.
I would like to access the Umbraco loggedin user id - so in my calls I am
...
This is actually returning the logged in user, which suggests that the web service is part of the main application session and has access to HttpContext.
My question is - is this reliable, ie is the web service always going to be able to query HttpContext, or is this going to be flaky?
is working on a reply...