Giter Site home page Giter Site logo

Comments (10)

lurumad avatar lurumad commented on June 12, 2024 1

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.

lurumad avatar lurumad commented on June 12, 2024 1

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.

lurumad avatar lurumad commented on June 12, 2024

Thanks @isrsuamar

I'm going to fix it as soon as possible!

Thanks!

from aspnetcore.hashids.

lurumad avatar lurumad commented on June 12, 2024

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.

isrsuamar avatar isrsuamar commented on June 12, 2024

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!

errorHash

2020-10-31 09-48-00.zip

from aspnetcore.hashids.

lurumad avatar lurumad commented on June 12, 2024

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.

isrsuamar avatar isrsuamar commented on June 12, 2024

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.

lurumad avatar lurumad commented on June 12, 2024

Hi @isrsuamar

Maybe I miss something. I've tried to create an E2E test

public async Task not_fails_when_retrieve_resources_by_hashid_that_does_not_exists()
to verifiy fake ids but only received a 404 for the hashid constarint.

Can you share your example, please?

Regards!

from aspnetcore.hashids.

isrsuamar avatar isrsuamar commented on June 12, 2024

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.

isrsuamar avatar isrsuamar commented on June 12, 2024

Hi @lurumad

Thank you, it is work fine. I close this issue.

Regards!

from aspnetcore.hashids.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.