Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Nicholas Budd
    @anaximander23
    hmm
    maybe I could do this using the full Map methods instead
    basically, I've been working with this framework I've developed for use in APIs that uses a Result<T> type to let you signal error results without exceptions, for cases where errors are expected and not exceptional
    so you can do stuff like return Results.NotFound<User>(query.UserId); rather than having to throw new UserNotFoundException(query.UserId);
    Michał Zegan
    @webczat
    minimal api is minimal for a reason... and other map methods are doing direct route mapping to a low level request delegate
    Nicholas Budd
    @anaximander23
    so, we noticed that now that I've implemented automated mapping of Result<T> types to relevant HTTP results, all our controller methods are identical
    literally just
    var result = await _mediator.Send(query);
    return MapToResponse(result);
    in every controller method
    SQL-MisterMagoo
    @SQL-MisterMagoo
    Nicholas Budd
    @anaximander23
    so I was wondering if there's a way to hook up something that registers that for stuff, but using different types of query
    I have it working mostly, but it's complaining that the body type is inferred and that's not allowed

    Custom Binding

    that looks promising but might require consuming applications to write binders for everything

    which... isn't the worst thing, but I was hoping to avoid it
    that said... in theory I could pull the URL, body, and query params into a collection, right?
    in fact that's probably already available
    just a flat dictionary of values
    and then use something like AgileMapper to map those onto the query object
    do that in a base type
    ...this is all probably a horrible abuse of Minimal APIs
    image.png
    but if I can get it working then you can define a whole API like this
    and then just write a load of handlers
    (it uses MediatR under the hood)
    Lari Tuomisto
    @shinpou
    any idea if I can somehow easily verify if model binding has occurred or not - I wish to verify that my uploaded files are actually being streamed without being loaded into memory
    Taylor
    @TaylorWatson

    hi guys :)

    If I have a URL as a string. Is there a way I can utilize the .Net's Query logic to automatically break up the parameters?

    https://duck.com?id=help&subject=me

    That's a string not a context, is there a simple way to convert it to something so I can just go Query["id"] or something similar?

    Thank you in advance :)

    nevermind, typing it out I remember about HttpUtlity ... duh, thanks for being my rubber duck guys

    https://docs.microsoft.com/en-us/dotnet/api/system.web.httputility.parsequerystring?view=net-6.0

    tag5
    @tag5
    Hello, I have an asp.net core web application hosted on an azure app service. Is it possible to remote debug this application from visual studio ? I have tried to remote debug an asp.net core web application hosted on an IIS web server. It works fine. But azure app service does not work with IIS. It seems to run dotnet run command. So i don't know how can i remote debug this app. Thanks
    Alok Sharma
    @aloksharma1
    Hello all, i need a little help with thread safe file writing to disk, i tried ReaderWriterLockSlim but it is not what i want (one write and many read) but still gets called on next requet
    basically i am creating disk files in middleware, so multiple users can concurrently hit the middleware and the scenario of using ReaderWriterLockSlim fails with recursion exception
    what i want is a queue like system, where on first request in pipeline the middleware create a unique write thread, so it doesnt matter if after first thread in queue a 100 users hit the request url or a 1000 the result will always be from FIFO based
    this files are write once type so i really dont need to re-initiations, re-writes whatever you want to call it
    how to achieve this in a thread safe manner
    Alok Sharma
    @aloksharma1
    solved my issue rabbitmq etc are overkill for my needs, this is a bit under so adding cutom layers on top of it atleast its thread safe
    the life of a programmer 🙂

    Hello, I have an asp.net core web application hosted on an azure app service. Is it possible to remote debug this application from visual studio ? I have tried to remote debug an asp.net core web application hosted on an IIS web server. It works fine. But azure app service does not work with IIS. It seems to run dotnet run command. So i don't know how can i remote debug this app. Thanks

    i think what you need can be inferred from here https://docs.microsoft.com/en-us/visualstudio/debugger/remote-debugging-dotnet-core-linux-with-ssh?view=vs-2022

    @tag5

    nevermind, typing it out I remember about HttpUtlity ... duh, thanks for being my rubber duck guys

    https://docs.microsoft.com/en-us/dotnet/api/system.web.httputility.parsequerystring?view=net-6.0

    you can also try json to split queries and remake them, i use this approach when i dont have access to httputility

    Nicholas Budd
    @anaximander23
    is there a specific object or service that handles model binding that I could invoke separately?
    got a slightly odd scenario where I basically want to replicate the ways that the various contents of an incoming request are bound to controller params
    wondering if there's something I could get from dependency injection and give it the request object from the HttpContext and the desired type, and it'd give me a populated instance
    Alok Sharma
    @aloksharma1

    wondering if there's something I could get from dependency injection and give it the request object from the HttpContext and the desired type, and it'd give me a populated instance

    so if i understand correctly, you want to DI specific HTTPContext Request query param & get the output based on that? can you put a example request i think what you need is already available using controller conventions and route sniffing

    Nicholas Budd
    @anaximander23
    @aloksharma1 so, I'm not in a controller, but I'm also not necessarily able to use things like [FromBody]; I've got access to the HttpContext and the DI container, and I have the desired type as a type parameter
    so given the argument T and a HttpContext, I'd like to be able to use some kind of BindToNewInstance<T>() method that'll give me an instance of T populated the way it would have been via model binding
    TeBeCo
    @tebeco
    try to see if you can resolve the modelbinder and use it
    Nicholas Budd
    @anaximander23
    yeah, I'm digging through the ASP.NET source to see if there's a visible type that I could resolve and use directly
    Palash Jhabak
    @palashjhabak
    Hi guys, I am stuck on a unique issue for quite some time. I have a blazor server application and if I change the folder name of default webroot folder and even if specify the new folder using UseWebRoot method, css and js file inside the new webroot folder does not get publised when I do dotnet publish. Have tried quite a lot of things but havent been able to solve it yet. Will appreciate any help
    Palash Jhabak
    @palashjhabak
    Anyone?