Getting Context User ID from Commerce Server Web Site in silverlight
Hi,
I'm developing a silverlight application which interacts with Commerce Server Agent API's to get the Categories / Products. We are able to get categories and products in Silverlight app. On the Similar lines i want to show the Wish List of a Particular User in the SL app, for this i need to have User ID of the user who is currently using the system (Correct me if im wrong).
How to get the user id / Context of the current user in the Silverlight App?
Will we be able to access the context of the current user if i depoly the SL app in virtuai Directory of the commerce server web Site?
Any help will be greatly appreciated.
Regards,
Rajesh.S
Answers
I think u are usinng statrtesite as base development for ur commerce server application.
If you see commercer server stores the userId(GUID) in cookie .
u can reed this cvookie by
Guid userId = new Guid(cookieParts[0]);
now u can user commerce context to get the userprofile of u can use
UserObjectProfile userProfile = UserObjectProfile.Get(userId);UserObjectProfile this is custom class u will find commerce server starter site.
If u are using forms authetication
then u can also use Membership.GetUser(username).ObjectProviderKey it will also return the same GUID,
Let me know if you want any more detail.
- Marked As Answer byHao Liu - CS Product TeamMSFT, ModeratorTuesday, January 06, 2009 5:50 PM
All Replies
Anybody from microsoft??Hi all,
OK, I thought whatever i posted earlier does not give the exact idea/scenario of the problem, so i have added some more details. I hope i will get some reply thi time.
I can get the Current User ID from CommerceContext if it is the same starter or commerce site. In our case, there are two sites, one is CS starter site and another is Silverlight web application which will access the CS data through CS Agent API’s. Now the problem is that, Silverlight app will be part of same virtual directory as starter site and there will be a link on the starter site to go Silverlight app.
Users who are using the starter site can also check the Silverlight app. Silverlight app will be having functionalities such as product browsing, comparison and wish list. If the user has already added some products in his wish list from starter site and then wanted to check the silverlight app then we will have to show what he has in his wish list. This is where the actual problem is. We cannot access anonymous user basket / wish list unless we have context user ID.
How can I get the current context user id in the above scenario?
I think this all will depend on how we deploy the Silverlight app. I tried deploying SilverLight app with CS starter site but every time I was getting Mixed Mode Authentication exception.
Can anyone guide us in how should we plan the integration of starter site and Silverlight app so that the system integrity is maintained?
Thanks in Advance,
Regards,
Rajesh.S
Gosh, no replies for two days on this post. I'm not able to believe that no single reply for this post.
Is it that complicated question / problem?
Is this forum being monitored by MSFT CS product team??
Anyways, if anybody not getting the problem, please post back. I will try still further.
Thanks in advance.
Regards,
Rajesh S
I think u are usinng statrtesite as base development for ur commerce server application.
If you see commercer server stores the userId(GUID) in cookie .
u can reed this cvookie by
Guid userId = new Guid(cookieParts[0]);
now u can user commerce context to get the userprofile of u can use
UserObjectProfile userProfile = UserObjectProfile.Get(userId);UserObjectProfile this is custom class u will find commerce server starter site.
If u are using forms authetication
then u can also use Membership.GetUser(username).ObjectProviderKey it will also return the same GUID,
Let me know if you want any more detail.
- Marked As Answer byHao Liu - CS Product TeamMSFT, ModeratorTuesday, January 06, 2009 5:50 PM
- I have the same issue, however, I believe that I can add to the requirement.
My problem is that I cannot assume that the starter site or any other "known" site is being used. I need to obtain the userid from CommerceServer with no knowledge of the underlying membership provider so that my solution can be flexible for any type of implementation.
As an example, some sites may implement the old CommerceContext.Current while others are using the Mojave API. I need a standard way to obtain the UserId that will work in all scenarios.
Thanks

