Asp.net Identity: cannot convert from CustomUserRole to IdentityUserRole - c#

Newbie here, I am experiencing the following error and I have no idea how to resolve the issue. I did change the primary key for users in Identity to int rather than it being stored as a string.(I believe that is what's causing the issue). Besides that, every other page runs perfectly. Any ideas on where to start?
CS1503 Argument 1: cannot convert from 'System.Collections.Generic.ICollection<DraftIntellectualProperty.Models.CustomUserRole>' to 'System.Collections.Generic.ICollection<Microsoft.AspNet.Identity.EntityFramework.IdentityUserRole>'
The error:
The method being called in the code-behind:
Snip from IdentityModel:
Snip from IdentityUserRole class:

Related

Cannot provide a value for property 'IconService' on type 'Microsoft.Fast.Components.FluentUI.FluentIcon'

I'm receiving the following error in browser:
Cannot provide a value for property 'IconService' on type 'Microsoft.Fast.Components.FluentUI.FluentIcon'. There is no registered service of type 'Microsoft.Fast.Components.FluentUI.IconService'.
https://learn.microsoft.com/en-us/fluent-ui/web-components/components/button?pivots=blazor
https://github.com/microsoft/fast-blazor/blob/main/examples/FluentUI.Demo.Shared/Pages/ButtonPage.razor
https://brave-cliff-0c0c93310.azurestaticapps.net/ButtonPage
This is when using example code from Microsoft Blazor:
<h3>With content and icon</h3>
<h4>With start</h4>
<FluentButton>
Button
<FluentIcon Name="#FluentIcons.Globe" Slot="start" Size="#IconSize.Size16" Filled=false />
</FluentButton>
A single button renders fine but when I use FluentIcon I get a runtime error.
I have followed this getting started guide:
https://learn.microsoft.com/en-us/fluent-ui/web-components/integrations/blazor
I have also looked at Icon examples but with no luck:
https://brave-cliff-0c0c93310.azurestaticapps.net/IconPage
You need to add the code below to Program.cs for your Blazor client. For some reason this is only documented on Github but not https://learn.microsoft.com.
builder.Services.AddFluentUIComponents();
https://github.com/microsoft/fast-blazor

View permission item of dynamic module auto change "Telerik.Sitefinity.DynamicModules.Model.DynamicContent" to [object%20Object]

issue img
Like you see above : 500 Type "[object Object]" cannot be resolved.
if i change [object Object] with Telerik.Sitefinity.DynamicModules.Model.DynamicContent then it works but i can not do that because this api call inside Sitefinity.
Sorry cause i do not enough 10 poin to add image!!
Version 11.1.6825.0
Step to reproduce :
login to backend page
Go to => Content / "Dynamic module Name"/ Action/ Permission
Actually it only happen with some Dynamic module, not all of them so i am also not sure what is happening.
Thanks for #Veselin Vasilev that correct after i remove FullName field it is fine.
Solution : Remove the field FullName.

Problem generating Swagger definitions using custom naming strategy

I have an OData Web API and I'm using Swashbuckle and Swagger to generate and display Web API documentation. This was working and producing nice definition names, like so:
User
Role
Permission
ODataResponse[List[Permission]]
CoordinateSystem
Etc...
I ran into an issue with "Conflicting schemaIds" after adding some new objects and controllers and started getting this error:
System.InvalidOperationException: 'Conflicting schemaIds: Duplicate schemaIds detected for types Microsoft.Spatial.CoordinateSystem and MyProject.CoordinateSystem. See the config setting - "UseFullTypeNameInSchemaIds" for a potential workaround'
As the error states, I added the following line in SwaggerConfig.cs
c.UseFullTypeNameInSchemaIds();
This fixed the error but caused some issues with my definition names. Now they show up like this:
MyProject.User
MyProject.Role
MyProject.Permission
Swashbuckle.OData.ODataResponse[System.Collections.Generic.List[MyProject.Permission]]
MyProject.CoordinateSystem
Microsoft.Spatial.CoordinateSystem
The third last one is problematic now as it is too long for the app that reads this information.
Next, I tried using the custom strategy example provided in SwaggerConfig.cs to rename one of the conflicting definition names:
c.SchemaId(t => t.FullName.Contains("Microsoft.Spatial.CoordinateSystem")
? t.FullName : t.Name);
This works for the conflicting definitions as it uses the full name for "Microsoft.Spatial.CoordinateSystem" and I get this now:
User
Role
Permission
ODataResponse`1
CoordinateSystem
Microsoft.Spatial.CoordinateSystem
The problem now is "ODataResponse`1". I'm expecting "ODataResponse[List[Permission]]" but it is displaying the name of the Swashbuckle.OData definition only. There are other options - I tried t.FullName, t.Name, t.AssemblyQualifiedName, t.Namespace but none produce the desired results.
I did come up with a solution that works using the custom naming strategy but it looks horrible and is super hacky:
c.SchemaId(t => t.FullName.Contains("System.Collections.Generic.List") ?
"ODataResponse[List[" +
t.FullName.Substring(t.FullName.IndexOf("MyProject.") + 10, (t.FullName.IndexOf(",") - 10 - t.FullName.IndexOf("MyProject.")))
+ "]]"
: (t.FullName.Contains("Microsoft.Spatial.CoordinateSystem") ? t.FullName : t.Name));
Does this seem to be a bug within Swagger/Swashbuckle or am I doing something wrong with the c.SchemaId code?

ASP.NET Core tutorial error 'The value 'http://msdn.com' is not valid for Url

I'm running the app in this Microsoft Tutorial and when I try to enter a url in the input box of the app (for instance, http://msdn.com or http://blogs.msdn.com/adonet as shown in the tutorial) and click submit I get the following validation error:
The value 'http://msdn.com' is not valid for Url.
When I debug the application I notice that in the following code of the tutorial the ModelState.IsValid value is showing as 'false'. What is missing here and how can it be fixed?
public IActionResult Create(Blog blog)
{
if(ModelState.IsValid)
{
_context.Blogs.Add(blog);
_context.SaveChanges();
return RedirectToAction("Index");
}
return View(blog);
}
Points to note:
I'm using latest ASP.NET Core 1.0 and VS2015-Update 3 [released on June 27, 2016] on windows 8.1
In the Creat.chtml view of the tutorial, <input asp-for="Url" class="form-control" /> was initially showing as readonly so I added type="text" attribute there and it became read/write
My app is an exact copy of the tutorial (I did copy/past) except that instead of choosing 'No Authentication' I chose 'Individual User Accounts' option when creating the poroject. But that, I think, should not make any difference.
UPDATE
I added var errors = ModelState.Values.SelectMany(v => v.Errors); just above if(ModelState.IsValid) statement and I see the following in the debug window showing the values of error collection but can't figure out the cause of error. Maybe. someone can help:
UPDATE 2:
I found my mistake. I was using int datatype in public int Url { get; set; } property of the Blog class instead of using string. Changed it to string and it's working now. Someone may help what the error in image is saying.
I resolved the issue. There was a mistake on my part. I was using the datatype int in the property public int Url { get; set; } of the Blog class. Changed it to string. Then deleted the database in SQL Server and corresponding migration folder in the project. Re-ran the package manager commands Add-Migration MyFirstMigration -context BloggingContext and Update-Database -context BloggingContext. It's working now. Although the app was a copy/paste from this Microsoft Tutorial, later I tried to test creating a property through a short-cut key as explained here but forgot that the short-cut key creates the datatype as int. Thanks to all the readers who may have tried to help.

Error in reCaptcha implementation in asp.net

I am following this tutorial : http://www.sieena.com/blog/archive/2010/10/05/how-to-add-recaptcha-to-an-asp-net-site.aspx to implement reCaptcha in my ASP.net website from VS2010 ... but i am getting a error like this
What might I have done wrong?
Have you changed keys
PublicKey="Your very own public key here" PrivateKey="Your very own
privat key here"
that you should get from your account?

Categories

Resources