Note: Create a separate PR with fixing all comments I left in this comment, please
File structure:
It looks like you have removed this folder using file explorer, but reference in solution still exists. Please, remove it:
The same case for wwwroot/Images folder.
https://github.com/osmanaliyardim/WebNetSample/blob/dev/WebNetSample/Controllers/ProductsController.cs#L55 - This route is built incorrectly: whenver you start your route name with / - it will overrider base route of controller. You should start with simple word and [controller]/ route will be automatically added. So, in your case, it will look like: [HttpGet("Update/{id}")] and endpoint will be available via /Products/Update/{id}.
https://github.com/osmanaliyardim/WebNetSample/blob/dev/WebAPI/Controllers/CategoriesController.cs#L76 - In my opinion it is absolutely redundant and can be removed. You have configured your global exception handler. In this case, you may easily throw exceptions in your Business layer and exception handler will return 400 status for specific exception types. Also, as far as I see from Business, your code will not be reproduceble, if no item exists 99% it will throw exception on Business layer;
Note: Create a separate PR with fixing all comments I left in this comment, please
File structure:
wwwroot/Images
folder.Code issues for WebNetMVC:
GetProducts
view exists), you should explicitly specify the name of view, like:return View("Index", productsWithDetails);
/
- it will overrider base route of controller. You should start with simple word and[controller]/
route will be automatically added. So, in your case, it will look like:[HttpGet("Update/{id}")]
and endpoint will be available via/Products/Update/{id}
.if (exceptionHandlerFeature?.Error is ValidationException validationException)
. In this case, you will not have to cast explicitly toValidationException
yourerrors
variables and may just leaveErrors = validationException.Errors
here;asp-controller
- will not be working, please, update withCategories
controller;Cannot resolve symbol 'AddWebOptimizer'
. Same case on 68 row. Please, fix this moment;Program.cs
is too overloaded. You may take a look into my solution here: https://github.com/dotnet-fizzyy/ASP.Net-Identity/blob/master/src/IdentityWebApi/Program.cs#L11;_
symbol;options.Authority += "/v2.0/";
Middleware*
;private
;UseExceptionHandler
;var errors = ((ValidationException)exceptionHandlerFeature).Errors;
[Http(Verb)]
attribute since you already started adding them, it will be better, clear and makes your code consistent;Code issues for WebApi:
/
symbol, it breaks your XML comment not valid (IDE warning). Please, add it to make it consistent with others (it should be///
, update for the next endpoint as well);successful*
;201
status code (created);successful
;204
status code (no content);