This type of error can happen if the DbContext has been disposed. Most likely the error is elsewhere in your code.
Also, please stop post screenshots of the code. Just post the actual source code using the Code Sample button.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello!
I am writing a Login Form for a site on the MVC Net Core 6 Web App, but I can't find out how I can fix this error. This error occurs when I am already sending the user's data for writing to the database. Before I created the Login column in Asp Net Users to record a unique user login, registration was successful - without this error.
Updating of the database - everywhere there is a records of the types:
b.Property<string>("Login")
.Has MaxLength(256)
.HasColumnType("nvarchar(256)");
Login = table.Column<string>(maxLength: 256, nullable: true),
I tried using "using" instead of await, fix initialization app.Use(async (context, next) => (removed/changed) - doesn't help.
What do you think such an error occurs?
Thank you!
This type of error can happen if the DbContext has been disposed. Most likely the error is elsewhere in your code.
Also, please stop post screenshots of the code. Just post the actual source code using the Code Sample button.
I found:
Cannot access a disposed object Object name: 'UserManager`1'
[cannot-access-a-disposed-object-object-name-usermanager1][1]
If another object has a reference to userManager and that object is disposed, it might be disposing userManager along with it. Another possibility is userManager requires some type of initialization which hasn't been done yet, and its properties throw a misleading disposed exception (this is common with winform controls).
But I don't delete the login form during the execution of the method: public async Task<IActionResult> Create(Application User user)