Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 313033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:04:15+00:00 2026-05-12T08:04:15+00:00

I am working on a Silverlight v3 web app and I would like to

  • 0

I am working on a Silverlight v3 web app and I would like to secure access to the WCF service I am using to fetch my data. I currently have the WCF working just fine, but it doesn’t require any user credentials.

I’m not very experienced with this aspect of WCF, so my first idea was to add username and password parameters to each of my service’s operations. The problem I have with this is that this would require a lot of redundant code, and the fact that the username and password would be transferred over the wire in plain text.

What I would like is a way to specify the credentials upfront on the client side right after I create my service proxy (I am using the proxy autogenerated from “Add Service Reference”).

Upon googling for a solution to this, I could only find solutions that similar to my first idea (using username/password parameters). Could someone please point me in the right direction?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T08:04:15+00:00Added an answer on May 12, 2026 at 8:04 am

    Where are these usernames and passwords coming from? If your web site already implements Forms authentication then you can bypass setting credentials yourself and use the forms authentication cookie. If your users are logged in then the cookie will travel with the web service call. In order to read it on the other side you need to make a couple of changes.

    First you need to enable ASP.NET compatibility mode for WCF in the system.ServiceModel section:

    <system.serviceModel>  
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" /> 
    </system.serviceModel>
    

    Once that is done then for each service method you want to understand the ASP.NET cookie add the [AspNetCompatibilityRequirements] attribute to your service class

    [ServiceContract]
    [AspNetCompatibilityRequirements(
        RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class ExampleService
    {
    }
    

    Now within each method you can access the HttpContext.Current.User.Identity object to discover the user’s identity.

    If you only want certain methods to be called by authenticated users then you can use a PrincipalPermission thus

    [OperationContract]
    [PrincipalPermission(SecurityAction.Demand, Authenticated=true)]
    public string Echo()
    

    As a bonus if you’re using ASP.NET’s role provider then those will also be populated and you can then use a PrincipalPermission on methods to limit them to members of a particular role:

    [OperationContract]
    [PrincipalPermission(SecurityAction.Demand, Role="Administators")]
    public string NukeTheSiteFromOrbit()
    

    And this works in Silverlight2 as well obviously.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a Silverlight app using the MVVM pattern. My ViewModel currently consists
I'm currently working on a Silverlight app and need to convert XML data into
I am working on a Silverlight 3 app with C#. I would like to
I'm working on some Silverlight controls and I would like to explicitly handle the
I am working on a silverlight app that you need to enter information into
I'm working on a Silverlight Polling control. My goal is to have a Button
Background: We have an offshore group working up a Silverlight 2 prototype for us.
Can anybody tell me why is this not working. I have created a WCF
I am writing silverlight 3 application which is working on network. It works like
I've been working in Silverlight recently and I've slowly been discovering that as simple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.