[Silverlight getting started series] extended webcontext. Current (authentication, roles, profiles)

Source: Internet
Author: User

For user logon, user roles, and profiles, how to use Asp.net membership and forms authentication mode to log on to the user to obtain the role and profile, how to create the authentication domain service of riaservice, there is a SilverlightBusinessapplicationTemplate to solve the above problems. For details, see msdn: Walkthrough: using authentication service with Silverlight business application, and WCF Ria service: authentication, roles, and profiles.Article.

Authentication, roles, Profiles
    • Authentication-authenticate the user's creden and mark the user as logged on or logged out.

    • Role-groups users according to their responsibilities and grants resource permissions to Members who have passed the authentication in the group.
    • Configuration File-keep attributes for authenticated users andProgram.
How to extend webcontext. Current

Webcontext is used to obtain and manage the Application Path context. Gets the context that is registered as a lifetime object with the current application. after you create the authenticationdomainservice in riaservice, add the rialinkWebcontext. Current. User,Webcontext. Current. Authentication.... Etc. You can easily obtain and manage the context information of user identities and roles. Note that if rialink reference to riaservice of authenticationdomainservice is added to the Silverlight project, generated_code will automatically generate the webcontext local proxy class: partial class webcontext: webcontextbase in the Silverlight project. In this way, we can callWebcontext. Current. User,Webcontext. Current. Authentication.... Etc. You can easily obtain and manage the context information of user identities and roles. EveryWebcontextIn the Silverlight project, generated_code automatically generates the webcontext local proxy class, which may cause a conflict.

Extends webcontext. Current to add custom attributes.

How to extend webcontext. Current to add custom attributes? For example, how do I obtain webcontext. Current. mycustomizeddata?

It is actually very simple. First, webcontext cannot be inherited. webcontext. Current is a static Singleton access and cannot be inherited. Therefore, to extend webcontext to add custom attributes, you can directly write a webcontext. Partial. CS file, as shown in the following code:

Public   Partial   Class Webcontext
{
// This is a custom class, which is replaced by your custom class.
Public Customizeddata mycustomizeddata
{
Get ;
Set ;< BR >}< P>

/// another attribute
Public ienumerable string > anotherfields
{< br> Get ;< br> set ;< BR >}

in this way, a custom attribute is added through webcontext. current. mycustomizeddata access.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.