Bypass Authorize Attribute in .Net Core for Release Version

前端 未结 6 1948
梦如初夏
梦如初夏 2020-12-07 02:20

Is there a way to \"bypass\" authorization in asp.net core? I noticed that the Authorize attribute no longer has a AuthorizeCore method with which you could use to make dec

6条回答
  •  無奈伤痛
    2020-12-07 02:46

    Expanding off of John_J's answer:

        public void ConfigureServices(IServiceCollection services)
        {
            ...
    
    #if DEBUG
            services.AddMvc(opts =>
            {
                opts.Filters.Add(new AllowAnonymousFilter());
            });
    #else
            services.AddMvc();
    #endif
        }
    

提交回复
热议问题