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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:28:55+00:00 2026-06-12T02:28:55+00:00

I am looking at the Rockstars example and ServiceStack.Razor. How do I go about

  • 0

I am looking at the Rockstars example and ServiceStack.Razor.

How do I go about fitting authentication into, say, secure.cshtml page. So I can redirect user to Login.cshtml if required.

I only understand from SocialBootstrapApi example if I mix MVC hybird, I can put [authenticate()] at ServiceStackController to achieve that.

But what if I just want a pure SS project without .net MVC?

  • 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-12T02:28:57+00:00Added an answer on June 12, 2026 at 2:28 am

    The Authenticate attribute is just a plain ServiceStack Request Filter Attribute, i.e. it works in both MVC and ServiceStack.

    Applying this filter will return a 401 UnAuthorized response for all non-HTML requests. e.g. If you called this with Ajax, you could detect this error response and do the redirect on the client.

    From v3.9.23+ of ServiceStack the [Authenticate] attribute will automatically redirect all Authentication errors to ~/login url by default.

    You can override this url when you register the AuthFeature, e.g:

    Plugins.Add(new AuthFeature(...) { HtmlRedirect = "/path/to/my/login" });
    

    Which will apply globally to all [Authenticate] attributes or you can override this on an adhoc basis with:

    [Authenticate(HtmlRedirect="/path/to/my/login")]
    

    Note: Attributes are inheritable so you can add this once to a SecuredService class and all subclasses will inherit its behaviour.

    Redirecting manually

    To redirect an UnAuthorized HTML request manually you can do your own checking + redirection with:

    public object Secured(Request request) {
        if (!base.SessionAs<MyCustomSession>().IsAuthenticated)
            return new HttpResult(HttpStatusCode.Redirect, "Un Authorized") { 
               Headers = { {"Location", "/path/to/login" } } };
    }
    

    There is also a DRY wrapper around the above redirect which you can use instead:

    public object Secured(Request request) {
        if (!base.SessionAs<MyCustomSession>().IsAuthenticated)
            return HttpResult.Redirect("/path/to/login");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Looking for a good example of how to set up child models in knockoutjs.
Looking for simple php class routing, like this: http://fatfree.sourceforge.net/page/routing-engine Is there a ready-made solutions?
looking into /usr/llvm-gcc-4.2/bin I have 544416 Oct 31 17:10 i686-apple-darwin11-llvm-g++-4.2* 544416 Oct 31 17:10
I'm looking for the coolest thing you can do in a few lines of
Looking at the example here - http://jsfiddle.net/uqYeQ/3/ The first row behaves as expected, returning
Looking for a way to capture user password in case of Tomcat form-based authentication
Looking for a C++ async HTTP library so I can download some zip files
Looking into ExtJS 4 and I am attempting to do the Hello World tutorial
looking for windows software who can draw a Use Case diagram like yuml.me anyone
Looking at this array, one can see that only the foo6 value differs from

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.