Is there a built in way of using snake case as the naming policy for JSON in ASP.NET Core 3?

I managed to get it working using the following code: .AddNewtonsoftJson(options => { options.SerializerSettings.ContractResolver = new DefaultContractResolver { NamingStrategy = new SnakeCaseNamingStrategy() }; }); However this makes MVC use Newtonsoft rather than System.Text.JSON which is faster, async and built in. Looking at the naming policy options in System.Text.JSON I could only find CamelCase. Is there…

ASP.NET Core 3: Cannot resolve scoped service ‘Microsoft.AspNetCore.Identity.UserManager`1[Alpha.Models.Identity.User]’ from root provider

When I run the project, I encounter this problem: (I’ve used asp.net core 3.) Cannot resolve scoped service ‘Microsoft.AspNetCore.Identity.UserManager`1[Alpha.Models.Identity.User]’ from root provider. How can I solve this problem? ApplicationDbContext class: public class ApplicationDbContext : IdentityDbContext<User, Role, int, UserClaim, UserRole, UserLogin, RoleClaim, UserToken> { public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { } public static async Task CreateAdminAccount(IServiceProvider…

Reuse ASP.NET Controllers and Services with DbContext hierarchy

Using ASP.NET MVC with .NET Core 2.2. I have several similar databases and have a hierarchy of DbContext such as: public class BaseContext : DbContext {} public class DerivedContext : BaseContext {} I have services and controllers that should work with both DbContext: public class MyService { public MyService(BaseContext dbContext) {} } public class MyController…

How Send Input Text And FileUploud Using Ajax In asp.net C#(Web Forms)

How Send Input Text And FileUploud Using Ajax In asp.net C#(Web Forms)? <input type=”text” id=”txtChanelName” class=”input-field” runat=”server” /> <input type=”file” id=”fpImage” class=”input-field” runat=”server” /> <button id=”btnInsertChanel” onclick=”return AddChanel(this.value);” value='<%=Session[“GroupId”].ToString()%>’ >add</button> And my javascript code as below <script> function AddChanel(groupId) { var chanelname = document.getElementById(“txtChanelName”); var file = document.getElementById(“fpImage”).files[0]; $.ajax({ type: “POST”, url: “../../Ajax/Chanel.aspx/AddChanel”, data: “{‘chanName’:'”…

ASP.NET Core Razor PageModel ModelState Invalid because of new Navigation Property with Id==0

I’m trying to update an entity that may have an optional NavigationProperty from an html form. public class ProcessDataGroup { public int Id { get; set; } public string Name { get; set; } public ReadDataGroupStrategy ReadDataGroupStrategy { get; set; } public ReadBlockDefinition ReadBlockDefinition { get; set; } public int? ReadBlockDefinitionId { get; set; }…

asp.net web api does not reach controller after basic authentication

im new in api and very much confused,i have implemented a basic authentication,it authenticate the user,and i get 200 status,but then why it does not reach my controller? my web api config: config.Filters.Add(new BasicAuthenticationAttribute()); // config.Filters.Add(new AuthorizeAttribute()); config.Routes.MapHttpRoute( name: “DefaultApi”, routeTemplate: “api/{controller}/{id}”, defaults: new { id = RouteParameter.Optional } ); // Uncomment the following line…