Comments (10)
Thank @isrsuamar
I've seen the error. I have to think on how manage this, throws an exeception or using a default value.
Regards!
from aspnetcore.hashids.
Hi @isrsuamar
Please check the new version of the package: https://www.nuget.org/packages/AspNetCore.Hashids/1.1.1-preview8
Feel free to close the issue if you want
Regards!
from aspnetcore.hashids.
Thanks @isrsuamar
I'm going to fix it as soon as possible!
Thanks!
from aspnetcore.hashids.
Hi @lurumad
I've added some tests to the solution, and I've tried to reproduce the error but I couldn't.
Can you share your example or a way to reproduce it?
Regards!
from aspnetcore.hashids.
Hi @lurumad ,
I send to you a short video as example. The example is very simple, it is a web api template in .NET CORE, and I have been able to reproduce the error as in mi original project. If it was necessary I could send you my example project.
Regards! Thanks!
from aspnetcore.hashids.
Hi @isrsuamar
I've seen your video and I know what's your problem. In order to translate the hashid to his integer value you have to configure two things at the action method level:
[HttpGet]
[Route("{id:hashids}")]
[Produces(MediaTypeNames.Application.Json)]
public ActionResult<CustomerDto> Get(
[FromRoute][ModelBinder(typeof(HashidsModelBinder))] int id)
{
return Ok(customers.SingleOrDefault(c => c.Id == id));
}
You need to add the route constraint {id:hashids} to match if the value is a correct hashid and also decorate with the modelbinder to translate to an integer [ModelBinder(typeof(HashidsModelBinder))] int id
You have a complete example here
Regards!
from aspnetcore.hashids.
Hi @lurumad
Thank you for your quick response. Sorry, because in my test project I forget put the decorate [ModelBinder(typeof(HashidsModelBinder))], but in my real project that is like that, and it is work fine.
My problem is not the HttpGet, but in Put and Post when they are false ids, that is, if for example I obtain the ids from a grid previously and I pass a real hashid through Get / Post / Put it works correctly. The problem is, when I force a wrong id on it, it fails and the error is logged.
Maybe, I haven't explained correctly. Thanks a lot!
from aspnetcore.hashids.
Hi @isrsuamar
Maybe I miss something. I've tried to create an E2E test
to verifiy fake ids but only received a 404 for the hashid constarint.Can you share your example, please?
Regards!
from aspnetcore.hashids.
Hi @lurumad
Thanks for the support. I'll send you a video again, and you can tell me if it is necessary for me to send the project. I hope to clarify the problem with that
2020-11-01 09-04-25.zip
and we close this thread.
Regards!
from aspnetcore.hashids.
Hi @lurumad
Thank you, it is work fine. I close this issue.
Regards!
from aspnetcore.hashids.
Related Issues (9)
- Support for Int64/long Ids HOT 1
- Signed integers not working
- Encode/decode Id in DTO
- Integración con MediatR y Swagger.
- HashIds not working after adding custom Output formatter
- HashidsModelBinder doesn't take in consideration whether the hash ID can be decoded when route constraint is not applied
- Not compatible with netstandard2.0 HOT 1
- Bypassing the hashing. HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aspnetcore.hashids.