Forum Widgets
Latest Discussions
Blazor server app closes without error during debugging
The application started in debug mode stops reacting unexpectedly, without errors being intercepted and/or exceptions being generated. I don't know if this behavior can also happen when starting in release mode. In practice, the web application stops reacting in the browser. However, if I pause the execution in Visual Studio, a message warns me that the debug has timed out because the underlying application is no longer running. The attempts I made to solve the problem are: I tried to hook the unhandled errors with: AppDomain.CurrentDomain.UnhandledException += (handling code) But unhandled errors are not intercepted. I tried to remove the automatic start of the browser when the app starts in order to disconnect the closing of the browser with the end of the execution of the application. It does not solve the problem. Notes: It is a Blazor server application, it uses .NET 9 (but even with .NET 8 I encountered the problem). I updated visual studio, and all the nughet packages connected to the application. The application, terminating without there being any clues as to the cause because the debugging does not stop anywhere, can no longer be fixed. Thanks I tried to catch unhandled errors, but it seems that the app does not close due to exceptions during execution (debugging does not catch errors). I use Edge browser. I tried to remove breakpoints from the code.KocahoctpaMar 26, 2025Occasional Reader6Views0likes0Comments.NET Core render modes
I moved my Blazor webassembly application form .NET 8 to .NET 9. Previously it was basicly two projects: Client (static webassembly content served in docker by nginx on port 5007 with API address set to port 5007) Server (database app with API on port 5009) and the typical usage was that I connect in the browser to port 5007, webassembly content was downloaded to the browser and display data gathered form the API on port 5007. After migration to .NET 9 I can no loger download web assemby package (connection reset), but instead everything is served on port 5009 (old webassemby content and API). Moreover everything is working considerably faster but I`m confused: Why and how it is even working (how content from client appear in the server)? Which render mode I`m using currently? Do I still need my second container with nginx? How should I clean my Startup.cs in the Server project after taht migration? namespace eTabelki.Server { public class Startup { readonly string CorsOrigins = "CorsOrigins"; public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { services.AddDbContext<ApplicationDbContext>(options => options.UseSqlite(Configuration.GetConnectionString("DefaultConnection"))); services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); services.AddControllersWithViews(); services.AddRazorPages().AddJsonOptions(options => { options.JsonSerializerOptions.ReferenceHandler = System.Text.Json.Serialization.ReferenceHandler.Preserve; options.JsonSerializerOptions.PropertyNamingPolicy = null; }); services.AddCors(options => { options.AddPolicy(CorsOrigins, builder => builder.WithOrigins("http://10.0.10.3:5007", "https://10.0.10.3:5008") .AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader()); }); services.AddTransient<IGenerateInvoiceService, GenerateInvoiceService>(); services.AddTransient<IExportService, ExportService>(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseWebAssemblyDebugging(); using (IServiceScope scope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>().CreateScope()) { var context = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>(); context.Database.Migrate(); ApplicationDbContextExtensions.EnsureSeedData(context).GetAwaiter().GetResult(); ApplicationDbContextExtensions.EnsureSeedTemplates(context).GetAwaiter().GetResult(); } } else { app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); using (IServiceScope scope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>().CreateScope()) { var context = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>(); context.Database.Migrate(); ApplicationDbContextExtensions.EnsureSeedTemplates(context).GetAwaiter().GetResult(); } } var cultureInfo = new CultureInfo("pl-PL"); CultureInfo.DefaultThreadCurrentCulture = cultureInfo; CultureInfo.DefaultThreadCurrentUICulture = cultureInfo; app.UseHttpsRedirection(); app.UseBlazorFrameworkFiles(); app.UseStaticFiles(); app.UseRouting(); app.UseCors(CorsOrigins); app.UseEndpoints(endpoints => { endpoints.MapRazorPages(); endpoints.MapControllers(); endpoints.MapFallbackToFile("index.html"); }); } } }barooMar 19, 2025Copper Contributor8Views0likes0CommentsJoin return red in visual studio
Hi everyone, I am newbe in .NET Core, please info what's wrong in my code? i want to join query using EF, but inside the visual studio tools, my join query return red. please see attached image bellow: the join return underline red so i can't run the project. how to fixed it? Thankyou and best regards.tomtom2xFeb 27, 2025Copper Contributor40Views0likes0CommentsIssue with SignIn Key validation while using Orcid as External login Provider with Identity Server
Hi, I am working on integrating Orcid as second external login provider in my Identity Server based SSO application in Asp.Net Core. I have added necessary configurations in startup.cs file for Orcid provider as below services.AddAuthentication() .AddOpenIdConnect("ORCID", "ORCID", options => { options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme; options.SignOutScheme = IdentityServerConstants.SignoutScheme; options.ClientId = {myclientid}; options.ClientSecret = {myclientsecret}; options.Authority = {authorityurl}; options.ResponseType = "code"; options.Scope.Clear(); options.Scope.Add("openid"); // ORCID-specific scope for basic authentication options.Scope.Add("/authenticate"); options.CallbackPath = new PathString({myapplicationpath}); options.GetClaimsFromUserInfoEndpoint = true; options.SaveTokens = true; options.Configuration = new Microsoft.IdentityModel.Protocols. OpenIdConnect.OpenIdConnectConfiguration { AuthorizationEndpoint = "https://sandbox.orcid.org/oauth/authorize", TokenEndpoint = "https://sandbox.orcid.org/oauth/token", Issuer = "https://sandbox.orcid.org" }; options.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters() { NameClaimType = "sub", RoleClaimType = "role" ValidateIssuer = true, ValidIssuer = "https://sandbox.orcid.org", ValidateIssuerSigningKey = true, ValidateAudience = false, // ORCID does not return 'aud' in ID token ValidateLifetime = true, RequireExpirationTime = true }; options.ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "orcid"); options.ClaimActions.MapJsonKey(ClaimTypes.Name, "name"); options.ClaimActions.MapJsonKey(ClaimTypes.Email, "email"); options.Events.OnAuthorizationCodeReceived = authorizationCtx => { // access code thru authorizationCtx.TokenEndpointRequest.Code var code = authorizationCtx.TokenEndpointRequest.Code; return Task.FromResult(0); }; options.Events.OnTokenResponseReceived = tokenResponse => { var idToken = tokenResponse.TokenEndpointResponse?.IdToken; var accessToken = tokenResponse.TokenEndpointResponse.AccessToken; Console.WriteLine($"Access Token: {accessToken}"); Console.WriteLine($"ID Token: {idToken}"); // Handle the response manually to prevent further processing tokenResponse.HandleResponse(); // Redirect the user to the callback path (or another page) var callbackUrl = {mycallbackurl}; // Change this to your desired redirect URL tokenResponse.HttpContext.Response.Redirect(callbackUrl); return Task.FromResult(0); }; options.Events.OnRemoteFailure = ctx => { ctx.HandleResponse(); ctx.Response.Redirect("/error?message=" + ctx.Failure.Message); return Task.CompletedTask; }; }).AddJwtBearer(options => { options.Authority = "https://sandbox.orcid.org"; options.Audience = {myclientid}; options.RequireHttpsMetadata = true; }); I am able to login to Orcid and receives authorization code and further receive access token and id token in OnTokenResponseReceived event. But after continuing, gets signature validation error as below IDX10501: Signature validation failed. Unable to match keys: kid: {orcid keyid} token: {token keyid}.... I verified the signin keys at both end and they are correct Can anyone suggest the cause of the error and how to fix it? How can I validate the signin key and return back to my redirect url? Or suggest a complete flow on how to implement this integration. Thanks.mayurib24Feb 13, 2025Copper Contributor39Views0likes0CommentsHow to stop "A potentially dangerous Request.Path" with "<"
Hello, I've been getting "A potentially dangerous Request.Path value was detected from the client (<)." recently and it is causing the application pools in IIS to stop working. The url they are trying to pass through is similar to this: https://test.com:443/cds/pubs/bib/<my_tag_9ac1214b650a30718aced57527fd64c4/> If users can past this URL at any point on my site, how can I stop it from constantly stopping my site and still being safe from SQL injection, Cross Site Scripting or some other vulnerability? Can I encode it before the page is processed so "<" becomes "<"? That way this will not be considered a dangerous Request.Path. Thank youJerry8989Feb 12, 2025Copper Contributor59Views1like0CommentsSolutions for Blazor problems
Hi, I've significantly reduced render times, section rendering and configuration, API exposure, ... And I am starting thinking of sharing. I've never done this before, so I am wondering how to offer my Blazor framework API. Feacures I've implemented: Defer rendering (on standard component level - as naturalrendering pipeline) Custom sections (with custom state proagation and optimization minimizing render requests - my sections allow for full generic settings usable in section definition component with any amount of RenderFragment or other parameters): <YourSection Param1="StateWatchedParam1" Param2="StateWatchedParam2"> <RenderFragment1> StateWatchedContent with single render on whole section outlet </RenderFragment1> <RenderFragment2> StateWatchedContent with single render on whole section outlet </RenderFragment2> </YourSection> Unit of Work system with unltimited dependency tree of steps described by FluentAPI and accessed only by input model from client side - thus limiting any API exposure. You would have to know descriptor, rights and then guess allowed steps and stil only can fill model with input data - nothing more ... LinQ projector pattern with lego building FluentAPI system - where any business logic can be break into named step in specific named projector, so you are out of ordinary expression tree completely. That projector pattern is correctly written to check for Queryable Provider and to work with the same expression tree also for Enumerable. (Thus the same lego pieces can work for client.) Blazor component messagging done on direct Task API system - so without any queue or backlog. You can directly pass any data between any Blazor component and you are doing it in direct way without any delay or data transfer. Here I have SignalR also in the same system - allowing server to communicate with any component needed. And whole system is communicating with ToastLogger, thus any issue/unhandled exception can be (and it is) instantly logged and toasted to user. Background runner - thus any Task in Blazor can be called to just RunInBackground and it is immediately handled in Task lock mechanism, Exception mechanism and with correct Blazor stae update pipeline thus allowing for partial renders and mid render switch to background process finishing later and rendering from that deferred background.RickettsialPoxFeb 09, 2025Copper Contributor37Views0likes0Comments[ASP.NET CORE] Exchange Web Services Throw HTTP 401 When Called from IIS
Hi, Currently, I can't get Microsoft.Exchange.WebServices to work with Exchange 2019 On-Premise. Send Email feature is working OK on Development but as soon I deployed it to IIS, it stopped working with following error: Microsoft.Exchange.WebServices.Data.ServiceRequestException: The request failed. The remote server returned an error: (401) Unauthorized. ---> System.Net.WebException: The remote server returned an error: (401) Unauthorized. at System.Net.HttpWebRequest.GetResponse() at Microsoft.Exchange.WebServices.Data.EwsHttpWebRequest.Microsoft.Exchange.WebServices.Data.IEwsHttpWebRequest.GetResponse() at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.GetEwsHttpWebResponse(IEwsHttpWebRequest request) --- End of inner exception stack trace --- at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.GetEwsHttpWebResponse(IEwsHttpWebRequest request) at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ValidateAndEmitRequest(IEwsHttpWebRequest& request) at Microsoft.Exchange.WebServices.Data.SimpleServiceRequestBase.InternalExecute() at Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.Execute() at Microsoft.Exchange.WebServices.Data.ExchangeService.InternalCreateItems(IEnumerable`1 items, FolderId parentFolderId, Nullable`1 messageDisposition, Nullable`1 sendInvitationsMode, ServiceErrorHandling errorHandling) at Microsoft.Exchange.WebServices.Data.ExchangeService.CreateItem(Item item, FolderId parentFolderId, Nullable`1 messageDisposition, Nullable`1 sendInvitationsMode) at Microsoft.Exchange.WebServices.Data.Item.InternalCreate(FolderId parentFolderId, Nullable`1 messageDisposition, Nullable`1 sendInvitationsMode) at Microsoft.Exchange.WebServices.Data.EmailMessage.InternalSend(FolderId parentFolderId, MessageDisposition messageDisposition) I'm using same Exchange Settings (URL, Credentials, etc.) for both instance but it is only worked on Development. My Site is using App Pool User which is registered on Exchange Mailbox Users. How to fix this issue? Thanks in advance. Best Regards, HenochjazzyhackerFeb 02, 2025Copper Contributor82Views0likes0CommentsI want to use VS code instead of Visual Studio for .Net Framework 3.5 or .Net Framework 4.8 project
I’m transitioning from Visual Studio to Visual Studio Code for .NET Framework 3.5 and 4.8 projects but facing difficulties with: Debugging: Setting up a debugger for seamless support. Resource Files (.resx): Editing/viewing with auto-generation of designer files. DBML Files: Managing these and their designer files effectively. How to execute the Unit tests? Are there any extensions, workflows, or best practices in VS Code to handle these issues?puneet_groverDec 27, 2024Copper Contributor73Views0likes0CommentsMulti-project launch profiles not working
Hi, I am using Visual Studio 2022 (version 17.12.3) for an ASP.NET + React project. I want to take advantage of the new launch profiles feature to have multiples profiles for http and https, edge and chrome, etc. The feature is enabled, and I am able to create my profiles. So far so good. I have even ticked the share box so a .slnLaunch has been created. But when I am back to the main VS screen, I don't have the dropdown list in my toolbar to chose the profile to launch. I just have the old tooldbar : I tried to : Restart VS Restart my PC Disable/enable the feature with VS restarts in between Sorry for the screenshots in french btw ;) Thanks in advance !AlexTekeufDec 05, 2024Copper Contributor145Views0likes0Comments
Resources
Tags
- ASP.NET Core148 Topics
- ASP.NET (Classic)79 Topics
- Web API61 Topics
- Blazor60 Topics
- mvc53 Topics
- Razor Pages35 Topics
- IIS.NET27 Topics
- security26 Topics
- SignalR5 Topics
- community1 Topic