Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
    Palash Jhabak
    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
    Jose Camilo
    Any particular reason you want to change that folder's name?
    Alok Sharma

    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

    i dont think you can hit HTTPContext or similar pipeline without a proper request route

    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

    if you are using visual studio (not code) then you can do this using folder property and include as content


    Hi guys,
    here is some t-sql query i have:

    declare @dmin datetime = cast('2022-05-01' as datetime);
    declare @dmax datetime = cast('2022-06-01' as datetime);
    with core as (
            productid, AmountInStoreBefore, AmountInStoreAfter 
            , ROW_NUMBER() over (partition by productid order by created asc) rn
        from ProductBatchTransfers
            created between @dmin and @dmax
        core.productid, core.AmountInStoreBefore,
    from core
    inner join (
            productid, max(rn) edgern 
        from core
        group by productid
    ) grp 
        on core.productid = grp.productid
    inner join core core2 
        on core.productid = core2.productid and grp.edgern = core2.rn
        core.rn = 1

    i think its prety self explanatory, so, the questions are:
    1) is there a way to create something similar with entityframework ?
    we are talking about .net462
    2) Is query good enough or i can improve it somehow (i am realy not enough good in t-sql)

    Isobel Cullen
    When calling AuthorizationHandlerContext.Fail is there a way to return the failure message to the client? Nothing that I have tried or found online has worked.
    Muhammad Waleed Hafeez
    has anyone used NextJs with asp.net core for web development?

    who can tell me what workaround may be for publlicating .net6 project in docker?
    i have this structure of folders


    i am trying to publish web-api project from project-solution
    the project-solution has reference to common-solution/shared-project-a
    and web-api has reference to shared/shared-project-a
    debugging in docker works like a charm but publishing fails with error: the imported project was not found '/shared-solutions/common-solution/shared-project-a' confirm that the expression in the import declaration '../../../shared-solutions/common-solution/shared-project-a' is correct

    i think this is because of docker context does not have shared-solutions/**/* but i am not sure. it strange that debugging works. i thought that docker context builded with respect to shared projects out of solution.

    does vs2022 can handle such scenarios? i mean when you build something with links to shared projects laying out of solution folder?

    Thomas Ottenhus

    A contributor from the AspNetCore Docs pointed me here, and I hope I might shed some light on a problem I've encountered.
    AspNetCore 7 will embrace the ProblemDetails usage (which is good).
    But there's no guidance about using the ProblemDetails class in client code.
    Referencing the Http.Abstractions DLL in e.g. a Blazor-WASM project seems odd.

    Implementing a "copy-cat" class seems unneccesary.
    What's the approach people are using? (Perhaps even in combination with nswag client generation and shared Models)

    sechelé delaruse
    re: cors requests with attached bearer tokens - i'm trying to optimize/eliminate the preflight time for such requests and i want to know if the following code is synononymous with allow any origin - please advise
            opts.AddDefaultPolicy(builder =>
                     .SetIsOriginAllowed(hostname => true); // the developer friendly 'local' setting (outside the librar)
                     // .WithOrigins("https://localhost:4200", "http://localhost:4200");

    Hi. Question about .net AOT here, specifically MAUI on android.

    If my understanding of AOT is correct, the assemblies are already compiled to native codes and I can confirm this with all the .so file in the apk.

    However when doing performance check with dotnet-trace, I still see a lot of JIT being done killing the startup time of the app.
    The apk is built for AOT everything in release mode with

    <PropertyGroup Condition="'$(Configuration)' == 'Release'">

    But yet there is a lot of System.Private.CoreLib!System.Runtime.CompilerServices.RuntimeHelpers.CompileMethod(object) in the call stack taking good amount of time.

    I attach my speedscope json file.

    dotnet --version
    Matt Boyle
    Hi everyone, I'm learning ASP.NET core and I'm running into an issue with dependency injection. I have an model class, Game, and a public DbSet<Game> Games { get; set; } property on my DbContext. I've requested an ILogger<Game> in the constructor of the Game class. When I try to use the collection, I get an error reporting that the logger parameter cannot be bound. Constructor DI like this works fine in a controller - can I not use it in an EF core model?
    I've been reading documentation and googling, but I can't seem to find a clear message around where/when DI can be used. Ultimately, I want to inject my own singleton service into this class. That also wasn't working so I was testing ILogger first to rule out an issue with my service installation.
    Alberto Passalacqua
    you are trying to define a logger using the same type being defined and constructed?
    Matt Boyle
    Indeed. And as you say that, it sounds problematic. :) I'm just copying a pattern I had in a controller which does work (e.g. public GamesController(DatabaseContext context, IMapper mapper, ILogger<GamesController> logger)).
    Alberto Passalacqua
    ILogger does not need a type
    there is an untyped version
    Matt Boyle
    Ok, I'll try again sans type.
    Still failing unfortunately.
    System.InvalidOperationException: No suitable constructor was found for entity type 'Game'. The following constructors had parameters that could not be bound to properties of the entity type: cannot bind 'logger' in 'Game(ILogger logger)'.
    Alberto Passalacqua
    without seeing your code...
    Matt Boyle
    I can copy more in, one second. Thanks for the help!
    AlbertoPa @AlbertoPa is headed out
    Matt Boyle
    (In Game.cs)
        public Game(ILogger logger)
    (In DatabaseContext.cs)
    public class DatabaseContext : DbContext
        public DatabaseContext(DbContextOptions<DatabaseContext> options) : base(options) { }
        public DbSet<Game> Games { get; set; } = null!;
    (In Program.cs)
    var builder = WebApplication.CreateBuilder(args);
    builder.Services.AddDbContext<DatabaseContext>(opt =>
    Matt Boyle
    Been debugging a bit, and re-reading that error, it seems like it's attempting to fill in properties of the Model (record values) rather than resolving a service..
    Ok, and now I'm finding better search results.. Sounds like this is possible, with some work, but it's antipattern I should avoid. Thanks anyway folks!
    Hi guys
    i have a published (production) web site (.net472)
    also there is my local copy of this web site.
    i am using SmtpClient to send messages from this website
    both local and production web sites has same smtp configuration but production can not send message while local succesfully send messages.
    i am struggling to determine the reason.
    client.Send(email) throws an exception with message something like: The attempt to establish a connection was unsuccessful, because the desired response was not received from another computer in the required time, or an already established connection was terminated due to an incorrect response from an already connected computer
    i've checked tls config - both have the same ssl3, tls.
    smtp server is available from production network.
    don't know what to check else, any thoughts?
    ok. i've solved this.
    Is anyone using hotrelaod here. I mean doest it ever work for you.
    Zavada Serhii
    Hi. Could you tell me if there is any way to find out in runtime how many active sessions are currently on Kestrel.