Prevent 401 changes to 302 with the utility

I am more likely to be new to the service program. I seem to be having problems writing 401 statues to 302. I looked at this answer:

If ServiceStack authentication failed, do not redirect?

I see that the proposed solution is as follows:

Plugins.Add(new AuthFeature(...) { HtmlRedirect = null }); 

My question is: where exactly am I adding this to make it work? I started creating something based on github examples:

 public class AppHost : AppHostBase { public AppHost() : base("Custom Authentication Example", typeof(AppHost).Assembly) { } public override void Configure(Container container) { // register storage for user sessions container.Register<ICacheClient>(new MemoryCacheClient()); // add routes Routes.Add<HelloRequest>("/hello"); // Register AuthFeature with custom user session and custom auth provider Plugins.Add(new AuthFeature( () => new CustomUserSession(), new[] { new CustomCredentialsAuthProvider() } )); // Enable the metadata page SetConfig(new EndpointHostConfig { EnableFeatures = Feature.All.Add(Feature.Metadata) }); } } 

thanks a lot

+4
source share
1 answer

You are there very much.

 public override void Configure(Container container) { Plugins.Add(new AuthFeature(() => new AuthUserSession(), new IAuthProvider[] { new BasicAuthProvider() }) { HtmlRedirect = null }); //... more config stuff... } 
+2
source

Source: https://habr.com/ru/post/1502673/


All Articles