求助:为何出现“Exception:correlation failed”异常?
Hey, let's break down how to track down this issue based on what you've shared so far. You tested across Chrome and Firefox, which rules out browser-specific quirks like cached data or plugin conflicts—so focusing on backend config is the right call.
Here are targeted checks to zero in on the problem, using your ConfigureServices snippet as a starting point:
Validate your connection string first
Head to yourappsettings.json(or whichever config source you're using) and double-check theDefaultConnectionvalue. Make sure the server address, database name, and auth details (Windows integrated security or SQL credentials) are correct. If your password has special characters like@or\, ensure they're properly escaped. A quick test: copy the connection string into SQL Server Management Studio and try connecting—if that fails, your issue starts here.Ensure Identity is fully wired to your DbContext
Your code cuts off at.AddEntityFramework...—make sure you're completing that line with.AddEntityFrameworkStores<ApplicationDbContext>(). This is the critical step that links Identity's user/role storage to your EF Core context. Without it, Identity can't access the database to handle authentication, which will throw all sorts of silent or vague errors.Check your ApplicationDbContext setup
Verify thatApplicationDbContextinherits fromIdentityDbContext<ApplicationUser>(orIdentityDbContext<ApplicationUser, IdentityRole, string>if you're using roles). If you've overriddenOnModelCreating, make sure you're not accidentally overwriting Identity's default table mappings—you should callbase.OnModelCreating(modelBuilder)first to preserve the default Identity schema before adding your own customizations.Confirm your config is loading correctly
Sometimes the problem isn't the config itself, but that your app isn't loading the right config source. Add a quick debug line inConfigureServicesto print the loaded connection string:var connectionString = Configuration.GetConnectionString("DefaultConnection"); Console.WriteLine($"Loaded Connection String: {connectionString}");Run your app and check the console—if the output doesn't match what you expect, you might have an environment mismatch (e.g., loading
appsettings.Production.jsoninstead ofDevelopment) or environment variables overriding your config file.
If you're still stuck, turn on detailed error logging. In development mode, you can enable the developer exception page to get a full stack trace—this will usually point directly to the broken piece of config or missing setup step.
内容的提问来源于stack exchange,提问作者banafys

