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 9244477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:02:38+00:00 2026-06-18T09:02:38+00:00

I’m trying to design a web application that would user WCF services to access

  • 0

I’m trying to design a web application that would user WCF services to access data and provide business logic. So in general the whole system would look like that:

UI (ASP.NET MVC)
BusinessLayer (WCF Services)
DataLayer (Entity Framework)
Date (SQL Server Database)

All parts of the system will resist on the same, closed environment, so I’m going to use Certificates to secure ASP.NET <-> WCF connection. Database connection would use standard EF securities, Connection String and Windows Authentication.

The application has to provide authentication and authorization functionality. I’m going to move most of that into ASP.NET, so there will be ValidateUserAuth() service method, which will be used to validate credentials, but the result (with UserRole that user belongs to) will be then used by ASP to create user session.

After that, every Service Method call needs to know the UserRole of current user, to return proper results (or say ‘Access denied’ if it’s necessary). Problem is I don’t want to pass that UserRole as a parameter for every Service Method! I’d like to make it happen automatically. Is it even possible with WCF?

All I need is:

  • Every service call made from ASP.NET app will be extended with User data taken from current ASP Session.
  • Service Method invoked by that call will be able to recieve that User data and use it to provide results according to user permissions.
  • All this would happen somekind on background, so there will be no additional UserDetails method parameter added to every Service Method exposed from Service.

I read a lot about WCF itself, but found anything that could met my requirements. I hope I just missed it and it’s still possible.

  • 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-06-18T09:02:39+00:00Added an answer on June 18, 2026 at 9:02 am

    I decided to use MessageInspector for that:

    On Client-side:

    Public Function BeforeSendRequest(ByRef request As System.ServiceModel.Channels.Message, channel As System.ServiceModel.IClientChannel) As Object Implements System.ServiceModel.Dispatcher.IClientMessageInspector.BeforeSendRequest
        Dim requestMessageProperty = New HttpRequestMessageProperty()
    
        Dim currentUser = Authentication.AuthenticatedStaffcareUser
    
        If currentUser Is Nothing Then Throw New ApplicationException()
    
        requestMessageProperty.Headers("UserName") = currentUser.UserName
        requestMessageProperty.Headers("UserId") = currentUser.UserID
        requestMessageProperty.Headers("UserRole") = currentUser.UserRole
        requestMessageProperty.Headers("EffectiveDate") = currentUser.EffectiveDate
        request.Properties(HttpRequestMessageProperty.Name) = requestMessageProperty
    
        Return Nothing
    End Function
    

    And Server-side:

    Public Function AfterReceiveRequest(ByRef request As Message, channel As IClientChannel, instanceContext As InstanceContext) As Object Implements IDispatchMessageInspector.AfterReceiveRequest
        Dim messageProperty = CType(OperationContext.Current.IncomingMessageProperties(HttpRequestMessageProperty.Name), HttpRequestMessageProperty)
    
        Dim userName = messageProperty.Headers("UserName")
        Dim userId = Integer.Parse(messageProperty.Headers("UserId"))
        Dim userRole = messageProperty.Headers("UserRole")
        Dim effectiveDate = DateTime.Parse(messageProperty.Headers("EffectiveDate"))
    
        Dim identity = New AppServerUserIdentity(userName, userId, userRole, effectiveDate)
        Dim principal = New AppServerUserPrincipal(identity)
    
        Threading.Thread.CurrentPrincipal = principal
    
        Return Nothing
    End Function
    

    I also had to set custom AuthorizationPolicy to prevent standard one from overwriting Thread.CurrentPrincipal:

    Public Function Evaluate(evaluationContext As EvaluationContext, ByRef state As Object) As Boolean Implements IAuthorizationPolicy.Evaluate
    
        Dim principal = TryCast(Threading.Thread.CurrentPrincipal, AppServerUserPrincipal)
    
        If principal Is Nothing Then
            Return False
        Else
            evaluationContext.Properties("Principal") = principal
            Return True
        End If
    End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to create an if statement in PHP that prevents a single post
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace

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.