Total Page Preview:   000000000169

What is allows anonymous in Asp.Net Core MVC in Engish and Hindi

 Allow Anonymous in English

In ASP.NET Core MVC, the AllowAnonymous attribute is used to specify that a particular action method or controller should not require authentication. This means that users can access the action or controller without being authenticated. This attribute is often used in scenarios where you want to allow both anonymous (unauthenticated) and authenticated users to access certain parts of your application.

Here's an example of how to use the AllowAnonymous attribute in ASP.NET Core MVC:
In the example above:
1-The HomeController controller is decorated with the [Authorize] attribute, which means that by default, all actions within this controller will require authentication unless otherwise specified.
2-The Index action method is decorated with [AllowAnonymous], which means that this specific action can be accessed by both authenticated and unauthenticated (anonymous) users.
3-The SecurePage action does not have the [AllowAnonymous] attribute, so it will inherit the [Authorize] requirement from the controller level, meaning that only authenticated users can access it.
 
By using [AllowAnonymous], you can selectively allow anonymous access to specific actions within a controller while requiring authentication for others. This can be useful when you have a mix of public and secure pages in your application.
 
 

 Allow Anonymous in Hindi

ASP.NET Core MVC mein AllowAnonymous attribute ka istemal kisi specific action method ya controller par authentication ki avashyakta ko hata kar, unko bina authentication ke access karne ke liye kiya jata hai. Yani is attribute ka upayog un sthano par hota hai jab aap chahate hain ki kuch parts of your application ko anonymous (non-authenticated) aur authenticated users dono ke liye access karne diya ja sake.
Yahaan ek ASP.NET Core MVC mein AllowAnonymous attribute ka istemal karne ka udaharan diya gaya hai:
Is udaharan mein:
1-HomeController controller ko [Authorize] attribute se sajaya gaya hai, iska matlab hai ki is controller ke andar ke sabhi actions ko default taur par authentication ki avashyakta hogi, yadi kuch aur specify nahi kiya gaya ho.
2-Index action method ko [AllowAnonymous] attribute se sajaya gaya hai, iska matlab hai ki is specific action ko authenticated aur non-authenticated (anonymous) users dono access kar sakte hain.
3-SecurePage action ko [AllowAnonymous] attribute se sajaya nahi gaya hai, isliye yah controller level par lagu ki gayi [Authorize] avashyakta ko inherit karega, iska matlab hai ki sirf authenticated users hi is action ko access kar sakte hain.
[AllowAnonymous] ka istemal karke aap controller ke andar ke kuch specific actions ko anonymous access karne ke liye allow kar sakte hain, jabki dusre actions par authentication ki avashyakta rahegi. Yah tab kaam aata hai jab aapke application mein public aur secure pages ka mishran ho.

 

 

Thank You

About Author

Brijesh Kumar

Database Developer

I have more then 6 years Experience in Microsoft Technologies - SQL Server Database, ETL Azure Cloud - Azure SQL Database, CosmosDB, Azure Data Factory, PowerBI, Web Job, Azure Function, Azure Storage, Web Apps, Powershall and Database Migration On-Premise to Azure Cloud.
LinkedIn : https://www.linkedin.com



Comments


                           
                           

                           

                           

Facebook User: