Posts

Upload File in .net core

Image
  We are going to understand uploading using the Add Product method, we have a product controller and inside that we have an Add Product method.  CODE REPO First we will create a model for AddProduct and set Validation to properties  Add IFormFile Type in Model to get the file see above image. Lets create AddProduct method and Use AddProduct Model  We can also configure Form option in Program.cs file  Run and upload the file using AddProduct API, File will be stored in uploads folder, Create folder before using this otherwise it will throw, we can auto create folder if not exists that code is not included here. Create an api to download the file see below image.

Middleware, Filter and Attributes.

Image
  Examples:  Attributes Aspect Filter Middleware Attribute Purpose Execute custom logic at specific points during the MVC request pipeline (e.g., before/after actions). Handle requests and responses globally or for specific routes; used for cross-cutting concerns. Add metadata to code elements for various purposes, often used with reflection. Scope Specific to MVC actions, controllers, or globally across MVC actions. Applied globally or to specific routes in the application. Applied to classes, methods, properties, etc. Execution Stage Executes before and/or after action methods, before and/or after results, or when exceptions occur. Executes during the request-processing pipeline; can short-circuit the pipeline. Executes at compile time or runtime, depending on how metadata is used. Configuration Configured in the MVC pipeline (e.g., via Startup.cs / (Program.cs v6 or later) or attribute-based). Configured in the Startup.cs / (Program.cs v6 or later) file. Configured by app...