Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info

    :newspaper: | .NET Framework 4.5.2, 4.6, 4.6.1 will reach End of Support on April 26, 2022


    you can't really remove a TFM constraint
    use an other version or rebuild the code yourself
    given that it's a tech that is almost 10yo, migrate ASAP to net48 minimal version
    (or .net5)

    I am getting 502 Bad gateway reverse proxy server , when i am accessing API.

    Configured krestel service port on 5001 and defined into appsetting.json

    I performed these steps

    1. Publish code through command for Linux :
      dotnet publish --self-contained -c Release -r linux-x64
    2. Copied published data on var/www/API folder
    3. Created krestel service with below configuration

             ExecStart=/usr/bin/dotnet /var/www/API/WebAPI.dll
             # Restart service after 10 seconds if the dotnet service crashes:
    4. tested krestel service and its working without any error.
    5. Now, I created site on nginx with below configuration
             server {
             listen        4001;
             location / {
                 proxy_pass         http://MachineNamewithDomain:5001;
                 proxy_http_version 1.1;
                 proxy_set_header   Upgrade $http_upgrade;
                 proxy_set_header   Connection keep-alive;
                 proxy_set_header   Host $host;
                 proxy_cache_bypass $http_upgrade;
                 proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
                 proxy_set_header   X-Forwarded-Proto $scheme;
    6. enabled site in sites-enabled directory..
    7. allowed or open 4001 ,5001 port on network.
    8. i made entry on /etc/hosts as well defined URL API
    9. reboot of machine.
    10. After reboot, I checked service is Up and running on port number 4001 .. I tried to access swagger and it is also working but
      when i am executing API its execute only once after that it is giving 502 bad gateway error.. I checked the logs there was nothing.
      11 then i tried to access krestel service , its also running and up.. I tried to access swagger , it is also working and able to access all API without any error.

    11. I configured krestel service URL (port number 5001) with Angular UI.. Application is working now but i observed two challanges there

      1. sometimes it is not responding and response is coming blank.. I check on browser network HTTPstatuscode 200
      2. Paralle request genrating from UI ( 20 requests of same single API ) in that case it is taking time and few requests converting into CORS error and getting response of some request.. i checked the log i am getting socket exception error
        2021-04-26 06:10:52,700 [139] ERROR System.Threading.Tasks.TaskCanceledException: The operation was canceled.
        ---> System.IO.IOException: Unable to read data from the transport connection: Operation canceled.
        ---> System.Net.Sockets.SocketException (125): Operation canceled
        --- End of inner exception stack trace ---
        at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
        at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.GetResult(Int16 token)
        at System.Net.Http.HttpConnection.FillAsync()
        at System.Net.Http.HttpConnection.ReadNextResponseHeaderLineAsync(Boolean foldedHeadersAllowed)
        at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken)
        --- End of inner exception stack trace ---
        at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken)
        at System.Net.Http.HttpConnectionPool.SendWithNtConnectionAuthAsync(HttpConnection connection, HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
        at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequ

    hey guys when init a singleton or scoped service. Is it possible to have two interfaces?

    I have IStateContainer for example, but I also have an IAbsorb interface as well.

    Is there a way to do
    services.AddSingleton<IStateContainer, IAbsorb, StateContainer>(); or something similar? So I can pass in either interface into other services or razor pages?

    oops, when registering a service **
    my mind went somewhere else and mixed two things

    ahhhh for those looking for the answer, I got it :)

    services.AddSingleton<Foo>(); // We must explicitly register Foo
    services.AddSingleton<IFoo>(x => x.GetRequiredService<Foo>()); // Forward requests to Foo
    services.AddSingleton<IBar>(x => x.GetRequiredService<Foo>()); // Forward requests to Foo

    odd but I get it I guess
    every single request create a scope inside Aspnetcore
    so using scoped services that are heavy to create will benefits from it
    or when you need to be sure vthat every layer of your app use the same instance of a thing during all that same request
    that's why a part of db context related stuff are scoped
    making sure you scale (each request has it own)
    but a request use the same "context" to not shoot you in the foot
    I share services between apps, and some apps need more inside the state container than the generic stuff. So this is helpful because like you said. I don't have to create the entire service to get access to the few things.
    "between apps" sound fishy
    can't tell
    the DI container only exists once per app
    if you are sharing things accros app maybe you need to use a distributed cache to store the data
    or just expose route
    I'm seeing some strange behavior with an ASP.NET Core application hosted in IIS. Regardless of what I have for Idle Time-Out and Recycling settings, it seems like IIS is restarting my worker process every minute. I can F5 in Task Manager and observe this...once a minute, the worker process restarts with a new PID. I'm using "OutOfProcess" hosting if it matters...has anyone else run into this?
    stdlogs include an "Application is shutting down..." message every minute if I have them enabled, meaning the process is getting a SIGTERM from IIS, not crashing. I can't figure out what could possibly be causing this
    ah, it seems to be a Virtual Memory limit on the app pool. I guess the runtime automatically reserves 2 GB (????) of Virtual memory immediately on startup, so it was "hitting" the limit right away. disabling that limit seems to have stopped the once-a-minute restarts (for now)
     UIRootWidget UI => new UIRootWidget
                Children =
                    new BannerWidget
                        Title = SelectedFamily.Descriptor.Name,
                        SubTitle = SelectedFamily.Descriptor.ShortDescription,
                        Description = SelectedFamily.Descriptor.Description,
                        Image = SelectedFamily.Descriptor.BannerImage,
                    new SectionWidget
                        Children =
                            new LayoutRowWidget
                                Children =
                                   //Error here
                                    SelectedFamily.Descriptor.Features.Select<string, Widget>(f=> new FeatureWidget
    How do populate a List Initializer from linq.
    Children is a List<Widget> and is protected set
    public class ContainerWidget : Widget
            public List<Widget> Children { get; protected set; } = new List<Widget>();
    Palash Jhabak
    Hi, I am trying to make a http request using HttpClient via a proxy. The proxy has to add a header in the response. But the proxy can only add the header if I make the request http and not https. But somehow HttpClient in the redirection phase from http to https follows the HTTP Connect (tunnel) protocol and not HTTP GET due to which proxy cannot read the headers. It is working absolutely fine in postman. Any way to force HttpClient to not use tunnel protocol ?
    Alok Sharma
    i am trying to invoke view component using vc tag helper but what shoudl be the assembly path for it
    i am using it in areas
    and this is my taghelper path i have defined
    but its not working
    @addTagHelper *, Project.MyModule.Areas.AuthManager.ViewComponents
    that is the folder where view component exists am i doing something wrong
    L Suarez
    Getting some strange behavior out of my IIS InProcess-hosted Core 3.1 app. OIDC security middleware is calculating the redirect_uri scheme to be HTTP instead of HTTPS. What am I missing to get my app to recognize that it's being requested over SSL?
    Alok Sharma
    @lsuarez5280 whats the middleware code?
    cant you simple check for httpcontext.request.host & path and correct url?
    Ashef Habib Tishad
    Suggest me some resources for practicing micro-services concepts. projects based learning is preferable.
    L Suarez
    @aloksharma1 figured out the cause is our load balancer forwarding requests internally over HTTP. Investigating https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/proxy-load-balancer?view=aspnetcore-3.1 now.
    Yurij Molchanov
    Hello guys. Any ideas how to implement multiple users cookie sign in defers by, for example, systemId. Aka, user with systemId=1 comes to sign in page -> aspnet core checks cookies for user with systemId=1 and shows status if he is authenticated. If not authenticated - authenticate him in cookie. Then if same user with systemId=2 come to sign in page - page should take all authenticated users from cookie, check if user with systemId=2 is authenticated. If user with with systemId=2 is not authenticated then show him a sign in page and after user signed in - add that user to cookie with systemId=2
    no clue what is SystemId to you
    are you speaking about Scheme ?
    and Challenge ?
    and Challenge on Scheme + SignIn on scheme
    never seen anything named "SystemId" in AuthN
    that's just specific to your project I guess so i can't tell about that
    Yurij Molchanov
    systemId is just another column in user table. and i need smth like google has. when you can choose between the users
    can someone tell me how to run task before building docker in vs2019?