Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    sake402
    @sake402
    I know the generator is running and is slowing things down because when I a attach JetBrain dotTrace to ServiceHub.RoslynCodeAnalysis, I could see it spending almost two minutes sometimes running my Execute method.
    Ian Davies
    @funkrider
    Hi, I have a .Net Core question - is there a way to dynamically change the view that an entity uses to retrieve data at runtime?
    Alok Sharma
    @aloksharma1

    Hi, I have a .Net Core question - is there a way to dynamically change the view that an entity uses to retrieve data at runtime?

    you need to use custom fileprovider or use razorruntimecompilation then you can simply edit cshtml file and it will recompile on next request

    Alok Sharma
    @aloksharma1

    a Razor ViewComponent question: is there a SIMPLE and STRONG way to let asp.net load the cshtml, instead of very strange not found cshtml behavior in ViewCompoent ?

    what do you mean by simple & strong way, view component if not found will always nd up in error

    Skeferstat
    @Skeferstat

    Hi, this thing makes me despair...
    I have an asp.net core app (service) inside a docker container. I have a docker-compose.yaml that starts this container.

    Port: 9010 --> 8070 (inside docker-compose)

    I use Consul for container registration and try to self-register my service. For that as I understand it, I need to know that the container is accessible from the outside via port 9010.

    That means my application has to ask in its source code on which external port it is running.

    For Consul registration I use:

    registration = new AgentServiceRegistration()
    {
    ID = $"{serviceName}:{uri.Port}",
    Name = $"{serviceName}",
    Address = $"{uri.Host}",
    Port = uri.Port            // <<< This must be the external port
    };
    
    consulClient.Agent.ServiceDeregister(registration.ID).ConfigureAwait(true);
    consulClient.Agent.ServiceRegister(registration).ConfigureAwait(true);

    You
    Thanks for help!

    Gary smith
    @Garysmi30407244_twitter
    Hi - any recommended source from recent years regarding "network printing" "label printing" in .net 6 ?
    TeBeCo
    @tebeco
    @Skeferstat a container cannot know how it's externally exposed you have to tell that to it
    the same kinda of issue apply for https redirect
    Skeferstat
    @Skeferstat
    @tebeco how I can do this? My ya
    Skeferstat
    @Skeferstat
    My docker-compose and my applications should than use one configuraion file with external ports? What if I create more instances of the same container? Should I update then the shared configuraion file? It is practicable?
    TeBeCo
    @tebeco
    via configuration
    choose your preferred way
    env / cli arg / file / mount / ...

    who does the port mapping ? the host
    who has to inform the container ? the host

    that's about it

    a static config file sounds like a bad idea if the host can decide to change port mapping later on
    env var from compose file is a possibility of you name that properly like ASPNETCORE__WHATEVER (i don't recall if it's one or two underscore)
    issue with that is that you have to put the env var into the compose file
    i wish there was a way to see -e from cli
    like
    docker compose up -e <service>:<env>:<value> but i don't think that's a thing
    Marcus Turewicz
    @marcusturewicz
    Hi all, I've got a Razor Pages app where I'm trying to create the following page: /venues/{venue-name}/gigs , where {venue-name} is dynamic. The best I've come up with is to create a Venues Razor Page with a page directive like @page "{venue-name?}/{gigs?}", then check in the code behind that gigs == "gigs", but this feel pretty wrong. Any ideas/suggestions?
    Marcus Turewicz
    @marcusturewicz
    Think I got it, TIL:
    services
        .AddRazorPages()
        .AddRazorPagesOptions(options =>
        {
            options.Conventions.AddPageRoute("/Venues/Gigs", "venues/{venuePath?}/gigs");
        });
    Alok Sharma
    @aloksharma1
    @marcusturewicz you know you can always use attribute routing, which gives much more control over routing options
    Alok Sharma
    @aloksharma1
    anybody know how to get Html pages with final output (javascript executed) with net 5/6, it seems webbrowser class is now legacy any chromium based alternative?
    2 replies
    CodingTank Limited
    @CodingTankLtd_twitter
    WebView2?
    Alok Sharma
    @aloksharma1

    WebView2?

    will try this too

    does anybody ever implemented filewatchers in asp.net core, all examples that i see are either dotnet tools or windows/service/console apps
    Alberto Passalacqua
    @AlbertoPa
    filewatcher for? do you want to show the output in a web page?
    Alok Sharma
    @aloksharma1
    i want to keep my css/js etc files precompressed
    Nicholas Budd
    @anaximander23
    so I'll preface this by saying I'm probably doing something unusual
    but
    when using Minimal APIs to map endpoints, is there a way to have it map the params to an object?
    so, when you do .MapGet("some/url/structure", (string foo, int bar) => HandleRequest(foo, bar));
    instead of having to explicitly delcare all the params foo and bar there, can you just give it MyRequestObject that has properties Foo and Bar and have it do model binding?
    Michał Zegan
    @webczat
    i think minimal api does not have advanced full featured model binding. it's minimal for a reason
    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