ASP.NET MVC 5 how to delete a user and its related data in Identity 2.0

I think the classes you’re looking for are the UserManager and the RoleManager. In my opinion they are the better way instead of going against the context directly. The UserManager defines a method RemoveFromRoleAsync which gives you the ability to remove the user (identified by his key) from a given role. It also defines several … Read more

Rotativa PDF generation working locally but not on IIS 7

This error is a missing C++ redistributable Package for Visual Studio 2013 file called (MSVCP120.dll). To solve the issue: Open the C++ redistributable Package for Visual Studio 2013 downloadable link below: download Visual C++ Redistributable Packages for Visual Studio 2013 Click Download and choose the file (vcredist_x86.exe) even if you are running X64 bit server … Read more

MapMvcAttributeRoutes: This method cannot be called during the application’s pre-start initialization phase

I recently upgraded my project to ASP.NET MVC 5 and experienced the exact same issue. When using dotPeek to investigate it, I discovered that there is an internal MapMvcAttributeRoutes extension method that has a IEnumerable<Type> as a parameter which expects a list of controller types. I created a new extension method that uses reflection and … Read more

EPPlus: how can I assign border around each cell after I apply LoadFromCollection?

If I know the amount of columns the model has, I can count the number of rows with a function and do this: var modelRows = exportQuery.Count()+1; string modelRange = “D1:F” + modelRows.ToString(); var modelTable = worksheet.Cells[modelRange]; Or, with more context. I verified that EPPlus will accept a string variable in Cells[], which allows me … Read more

How do you consume extra parameters in OAuth2 Token request within .net WebApi2 application

As it often is the case, I found the answer immediately after submitting the question… ApplicationOAuthProvider.cs contains the following code out-of-the-box public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context) { using (UserManager<IdentityUser> userManager = _userManagerFactory()) { IdentityUser user = await userManager.FindAsync(context.UserName, context.Password); if (user == null) { context.SetError(“invalid_grant”, “The user name or password is incorrect.”); return; } … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)