It's a while since my last blog , today i am gonna write an asp.net mvc image handler (Middle-ware) with following assumptions:
Step 1:Create ImageMiddleware class
Step 2:Create ImageMiddlewareExtensions class
Step 3:Register ImageMiddleware class in startup class
Source Code (Links on GitHub):
ImageMiddleware Class
ImageMiddlewareExtensions
Then in your startup class Add:
app.UseImageMiddleware("/images");
Testing:
My site url is : http://localhost:14600
http://localhost:14600/images?id=12&w=150&h=150
http://localhost:14600/images?id=12&w=400&h=400
- asp.net mvc core web application based on .net framework/.net core
- NuGet package for resize images Magick.NET-Q16-AnyCPU
- Image Manager in code used to get Image by id (replace it with your code)
- Image will be stored in Database (Binary + MimeType)
- Url will be {SiteUrrl}/images?id=xx&h=xx&y=xx
- id is image id in database
- h image height
- w image width
Step 1:Create ImageMiddleware class
Step 2:Create ImageMiddlewareExtensions class
Step 3:Register ImageMiddleware class in startup class
Source Code (Links on GitHub):
ImageMiddleware Class
ImageMiddlewareExtensions
Then in your startup class Add:
app.UseImageMiddleware("/images");
Testing:
My site url is : http://localhost:14600
http://localhost:14600/images?id=12&w=150&h=150
http://localhost:14600/images?id=12&w=400&h=400
No comments:
Post a Comment