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

  • Home
  • SEARCH
  • 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 8405147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:46:37+00:00 2026-06-09T22:46:37+00:00

I am following this article to authenticate users of a Web API service I’m

  • 0

I am following this article to authenticate users of a Web API service I’m writing :

http://codebetter.com/johnvpetersen/2012/04/02/making-your-asp-net-web-apis-secure/

This works just fine.

In summary, we use a custom action filter (that gets applied to all requests), that checks an encrypted request header to determine who the user is.

However, I also have code in my controller action methods that needs to know who the current user is. Rather than repeat the logic that has been executed in the ActionFilter, is there a way I can set a variable in the action filter and refer to that in the controller action method?

I have also seen it suggested that MessageHandler should be used rather than an actionFilter. Would that help in some way?

Essentially I need to somehow flag up who the current user is in the Filter code and be able to refer to that in my controller

Or am I way off here? Is ther a smarter way?
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-06-09T22:46:39+00:00Added an answer on June 9, 2026 at 10:46 pm

    Create a Principal and store it in Thread.CurrentPrincipal.

    You can then access it in the Web Api controller with User.Identity

    This method works on my machine.

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

Sidebar

Related Questions

I am following this article: http://www.lunametrics.com/blog/2011/12/01/automatic-cross-domain-tracking-revisited/ which leads me to put the following in
I was following this tutorial: http://www.vogella.com/articles/AndroidLocationAPI/article.html --> Paragraph 6.0 Problem: My emulator runs perfectly
I'm following this tutorial http://www.vogella.com/articles/AndroidIntent/article.html for having some data transfered to parent activity by
In C following this article ( http://blogs.msdn.com/oldnewthing/archive/2006/12/21/1340571.aspx ), we have succesfully been able to
I am following this article (http://blogs.msdn.com/b/kaevans/archive/2011/04/11/intro-to-windbg-for-net-developers.aspx )and it is saying download symbols from Microsoft
I am following this article series to learn about ROLLUP and CUBE http://beyondrelational.com/modules/2/blogs/28/posts/10471/tsql-lab-6-using-with-cube-to-generate-subtotal-and-grand-total-rows.aspx For
In this article: http://msdn.microsoft.com/en-us/library/ms171728(VS.80).aspx The author uses the following method to make thread-safe calls
I have a gridview and have modified it following this article: http://msdn.microsoft.com/en-us/library/aa992036.aspx#Y3473 to allow
I'm following this article ( http://asciicasts.com/episodes/160-authlogic ), I'm not using nifty generator tho. I've
I was following this article: http://msdn.microsoft.com/en-us/library/aa902637%28v=sql.80%29.aspx and my query for distinct count looks like

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.