I find myself in a bit of a pickle. I've been utilizing JavaScript's PageMethod feature and it's been working wonderfully. However, I'm running into an issue when trying to access the HttpContext's state, which is returning a value of "SYSTEM" for
HttpContext.Current.User.Identity.Name
that doesn't actually match the current User Name.
I know there are some possible solutions like storing HttpContext.Current in a Session or saving the Context's state in a custom container. But given the web farm environment I'm working with, I don't think those will work as intended.
Here's the code snippet I've been working on:
function MyFunction(){
PageMethod.MyPageMethod();
}
And here is the server method signature:
[System.Web.Services.WebMethod()]
public static void MyPageMethod()
{
// this returns "SYSTEM"
var user = HttpContext.Current.User.Identity.Name;
}
Interestingly, if I use the above code to access the user name in the OnLoad event of the page, it works perfectly fine and gives me the correct CurrentUserName.
I'm attempting to get this code to function properly in an ASP.NET Webform... :)
So, I'm left wondering if there's a way to access the actual current user in page methods without relying on sessions. Any help would be greatly appreciated.
NiK...