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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:43:33+00:00 2026-06-09T15:43:33+00:00

I have a ServiceStack project running an API at api.mydomain.com. An admin project in

  • 0

I have a ServiceStack project running an API at api.mydomain.com. An admin project in the same solution is hosted at admin.mydomain.com. Login/Logout is already handled by the admin application, but I want to make sure the user is authenticated (and sometimes check permissions as well) on my api calls. I’m using forms authentication across projects so the auth cookie is available to my api project.

Here’s my web.config authentication tag in the api project:

<authentication mode="Forms">
  <forms protection="All" loginUrl="home/denied" slidingExpiration="true" timeout="60" defaultUrl="home/denied" path="/" domain="mydomain.com" name=".myAuth"></forms>
</authentication>

Based on this Authentication and authorization post, I added an [Authenticate] attribute to a service method, expecting it to pass/fail based on the value of IsAuthenticated. However, it redirects to ‘home/denied’ everytime, regardless of whether the auth cookie is present. (I confirmed this by subclassing AuthenticateAttribute and examining the OriginalRequest… The cookie set when I logged in using the admin app is present and req.OriginalRequest.IsAuthenticated is true.)

Why is my request being redirected, and how do I properly utilize the existing auth credential set in the admin app?

EDIT: Here’s the solution I came up with. It simply requires an IPrincipal Identity to pass authentication.

public class AuthenticateAspNetAttribute : RequestFilterAttribute
{
    public override void Execute(IHttpRequest req, IHttpResponse res, object requestDto)
    {
        SessionFeature.AddSessionIdToRequestFilter(req, res, null); //Required to get req.GetSessionId()

        using (var cache = req.GetCacheClient())
        {
            var sessionId = req.GetSessionId();
            var session = sessionId != null ? cache.GetSession(sessionId) : null;
            var originalRequest = (System.Web.HttpRequest) req.OriginalRequest;
            var identity = originalRequest.RequestContext.HttpContext.User.Identity;
            if (!identity.IsAuthenticated)
                AuthProvider.HandleFailedAuth(new BasicAuthProvider(), session, req, res);

        }
    }
}
  • 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-09T15:43:35+00:00Added an answer on June 9, 2026 at 3:43 pm

    On the Authentication and autorization post you reference it reads:

    ServiceStack’s Authentication, Caching and Session providers are
    completely new, clean, dependency-free testable APIs that doesn’t rely
    on and is devoid of ASP.NET’s existing membership, caching or session
    provider models.

    Meaning it’s completely separate and has nothing to do with the ASP.NET’s existing Authentication providers. i.e. The client needs to make an explicit call to the /auth service to authenticate with ServiceStack web services.

    See the SocialBootstrapApi example demo project for an example of an MVC Website that uses and shares ServiceStack’s Authentication providers between MVC Controllers and ServiceStack web services.

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

Sidebar

Related Questions

I have created a servicestack MVC project, this I use as the main API
I have built a service with ServiceStack (customer example) as per this link: https://docs.google.com/present/view?id=dg3mcfb_213gsvvmmfk
I have some issue regarding REST API which i have built using servicestack. End
http://fluentvalidation.codeplex.com/wikipage?title=mvc vs http://www.servicestack.net/ Both have a library which seem to have the same classes.
I have just started to use ServiceStack which is an amazing library. However, I
Have deployed numerous report parts which reference the same view however one of them
Have a bunch of WCF REST services hosted on Azure that access a SQL
have created REST service using servicestack and in post request I have return object
I have been tinkering around with ServiceStack to expose some web services and have
I have constructed a simple Rest service using ServiceStack (which is brilliant), that returns

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.