asp.net-core-2.2

The SqlParameterCollection only accepts non-null SqlParameter type objects, not SqlParameter objects in Microsoft.Data.SqlClient

喜欢而已 提交于 2020-01-16 19:32:29
问题 I'm trying to use one of these namespaces //using Microsoft.Data.SqlClient; using System.Data.SqlClient; My model public class Get_Data_Scholar{ [Key] public Int32 ID_Transcript { get; set; } public string Year_Semester { get; set; } public string Period { get; set; } public string Status { get; set; } } My controller public JsonResult Get_GPA_Tuition (Int32 id) { var ID_NCS = new SqlParameter("@ID_NCS", id); List<Get_data> get_Data = new List<Models.Get_Data_Scholar>(); get_Data =

AspNetCore 3.0 - HTTP Error 500.0 - ANCM In-Process Handler Load Failure

十年热恋 提交于 2020-01-06 05:21:09
问题 I created two ASP.NET Core web applications - just API templates: ASP.NET Core 2.2 ASP.NET Core 3.0 Deployed these applications to the Windows Server 2016 with latest (3.0 Runtime & Hosting Bundle). ASP.NET Core 2.2 works correctly without any problems, but ASP.NET Core 3.0 gives me this error from image below. In event viewer I found error every time when I deploy or try to start 3.0 application: Application 'C:\Inetpub\vhosts\webapp.com\httpdocs\' failed to start. Exception message:

How to connect ASP.NET Core 2.2 Razor pages with MySql database?

自作多情 提交于 2020-01-06 04:31:12
问题 I'm developing an ASP.NET Core razor pages website since I'm a beginner. I'm trying to connect my web application with MySql database. Since I'm a beginner I don't really know how to connect my application with MySql database. I know how to connect with SQL Server, but I want to know about connecting to MySql. A complete working process with MySql and Asp.Net core 2.2 Razor pages would be much appreciated. 回答1: I suggest you take a look at Setup Entity Framework Core for MySQL in ASP.NET Core

Using EF Core 2.2 to decrypt a string using SQL Server DECRYPTBYKEY

若如初见. 提交于 2020-01-05 04:19:07
问题 Basically I have a POCO model that has a encrypted string. Using EF core 2.2. We use DECRYPTBYKEY to decrypt strings using SYMMETRIC KEY. I am using DBSet.FromSQL to pass in SQL query which calls open symmetric key, get the data including the decrypted value, close symmetric key. FromSQL only allows you to bring back an entity rather than a string by itself. I have tried adding an decrypted string value on the model and have tried to then set that in FromSQL query. This actually populates ok

Mock IOptionsMonitor

丶灬走出姿态 提交于 2020-01-03 10:47:54
问题 How can I make an class instance manually of a class that requires an IOptionsMonitor in the constructor? My Class private readonly AuthenticationSettings _authenticationSettings; public ActiveDirectoryLogic(IOptionsMonitor<AuthenticationSettings> authenticationSettings) { _authenticationSettings = authenticationSettings.CurrentValue; } My test AuthenticationSettings au = new AuthenticationSettings(){ ... }; var someOptions = Options.Create(new AuthenticationSettings()); var optionMan = new

How to create roles in ASP.NET Core 2.2 and assign them to users

狂风中的少年 提交于 2020-01-02 16:51:30
问题 I am using asp.net core 2.2 default web site template and authentication selected as individual user account. How can i create an "Admin" role and assign it to a user so that i can use role in controller to filter the access and let them see different pages. Here is what i found on the internet until now, but it doesn't work, because it says : ApplicationUser could not be found private void CreateRoles(IServiceProvider serviceProvider) { var roleManager = serviceProvider.GetRequiredService

The constraint reference 'slugify' could not be resolved to a type

ε祈祈猫儿з 提交于 2020-01-02 12:01:53
问题 ASP.NET Core 2.2 has introduced an option for slugifying routing url using Parameter transformer as follows: routes.MapRoute( name: "default", template: "{controller=Home:slugify}/{action=Index:slugify}/{id?}"); I have done the same thing as follows: routes.MapRoute( name: "default", template: "{controller:slugify}/{action:slugify}/{id?}", defaults: new { controller = "Home", action = "Index" }); My routing configuration in the ConfigureServices method as follows: services.AddRouting(option =

How to deploy a code-first Entity Framework database using Azure Devops pipelines to SQL server

烈酒焚心 提交于 2020-01-01 12:20:36
问题 We are building an ASP.net application using Entity Framework core with Azure DevOps and targeting IIS with MSSQL server 2016. Our test server is a local Windows 2016 machine containing both IIS and the SQL server instance. I have successfully written a deployment workflow enabling continuous deployment on that test server of the code itself but I can't find any way to deploy the database. The first version was targeting asp.net core 2.0 so I could use the command-line to start the

How to localize standard error messages of validation attributes in ASP.NET Core

廉价感情. 提交于 2019-12-25 01:47:25
问题 How to localize standard error messages of validation attributes in ASP.NET Core (v2.2)? For Example, [Required] attribute has this error message " The xxx field is required. "; [EmailAddress] has " The xxx field is not a valid e-mail address. "; [Compare] has " 'xxx' and 'yyy' do not match. " and so on. In our project we use not English language and I want to find a way how to translate standard error messages without writing them directly in every attribute of every data-model class 回答1:

Algorithm to calculate the nearest location (from the database) based on logitude & latitude

拜拜、爱过 提交于 2019-12-24 20:48:54
问题 What i want to do is develop an algorithm to calculate which known locations are closest to the selected location. Let's say i have 7 locations in the database and when the user selects one, he should have the option to see the, let's say, first 3 closest locations (from the database). In the database, each location is saved with latitude and longitude. Any idea on how i can do that? Example: Say the list contains 100 locations of bike stations. I am at station 5, and I want to find out what