12 September 2022

ASP.NET Core disable authentication in development environment

    You can bypass authorization in development environment by applying AllowAnonymousAttribute() to your endpoints. as below code 


 public void Configure(IApplicationBuilder app, IWebHostEnvironment env)

        {

           //-----------------------

            app.UseRouting();

            app.UseEndpoints(endpoints =>

            {

                if (env.IsDevelopment())

                    endpoints.MapControllers().WithMetadata(

                        new AllowAnonymousAttribute());

                else

                    endpoints.MapControllers();

            });

        //---------------------------

          }

How to Create and edit configurations in visual studio

 In Visual Studio you can create multiple build configurations for a solution, in addition to the built in configurations Debug and Release. For example Deployment, Test, Pre Production, Production and etc.

How to Create New or Edit Configuration in Visual Studio.

Step 1:  Go to Visual studio "Build" Menu and select "Configuration Manager" as below image


Step 2: As below image you can see New or Edit for configurations. click on New for create new one.


Step 3: In New Configuration window you can enter Name and select Copy Settings from then click on Ok button. it will create new configuration for your solution.

 


Step 4: I have created for Deployment, Test, Pre Production, Production. it will show all your solution configuration as below image in Visual studio.