Posts

Showing posts from June, 2024

API Should not Externally Accessed from Postman / Browser Asp.Net Core | API Should be accessed from JQuery Ajax of Same Website Only Asp.Net Core 3 or Above

At Controller Validate Using ; [ApiAuthorize(new string[] { "https://localhost:7161/", "http://xyz.com" })]  public class FarmerRegLoginController : Controller { ----------------------- ----------------------- ----------------------- ----------------------- Some Controller APIS Code ----------------------- ----------------------- ----------------------- ----------------------- } Create New Filter       public class ApiAuthorizeAttribute : TypeFilterAttribute     {         public ApiAuthorizeAttribute(string[] origins) : base(typeof(ApiAuthorizeFilter))         {             Arguments = new object[] { origins };         }     }     public class ApiAuthorizeFilter : IAuthorizationFilter     {         readonly string[] _origins;         public ApiAuthorizeFilter(string[] origins)     ...

Skip/Offset Rows from Table Data Result in SQL Server/ Postgres / Pagination

Skip/Offset Rows from Table Data Result in SQL Server/ Postgres  this is most helpful in pagination of data SELECT col1, col2, ...   FROM ... WHERE ... ORDER BY -- this is a MUST there must be ORDER BY statement -- the paging comes here OFFSET 10 ROWS -- skip 10 rows FETCH NEXT 10 ROWS ONLY ; -- take 10 rows If we want to skip ORDER BY we can use SELECT col1, col2, ... ... ORDER BY CURRENT_TIMESTAMP OFFSET 10 ROWS -- skip 10 rows FETCH NEXT 10 ROWS ONLY ; -- take 10 rows