asp.net-core-2.0

Entity Framework Database First .Net Core

流过昼夜 提交于 2020-07-06 10:44:34
问题 I have a .Net Standard 2.0 class library project and I want to add Entity Framework to it. I have added the Entity Framework Core package to the project but no Entity Framework Templates appear when I try to add a new item to the project. I have looked on the web and all I can seem to find is instructions for Code First! How do I get the database first functionality back? 回答1: EF Core does not, and will never, support the EDMX-based Database First workflow with the designer. EF Core stores

.net core , how to handle route with extra leading slash

我们两清 提交于 2020-07-03 15:16:18
问题 I need to handle an incoming request which is of the form: //ohif/study/1.1/series Note the exta slash at the front My controller signature is: [Route("ohif/study/{studyUid}/series")] [HttpGet] public IActionResult GetStudy(string studyUid) If I modify the incoming request to /ohif/study/1.1/series it works fine however when I use //ohif/study/1.1/series, the route is not hit Additionally I also tried: [Route("/ohif/study/{studyUid}/series")] and [Route("//ohif/study/{studyUid}/series")] Both

How to call a Repository on application startup using DI while creating HttpContext

一曲冷凌霜 提交于 2020-06-29 05:16:21
问题 I need to make a database call when the application starts up to set up some cache. I have custom DbContext class which has a HttpContext within to hold the current sql connection as follows: public sealed class DataContext : IDataContext { IDbConnection connection = null; IDbTransaction transaction = null; Guid id = Guid.Empty; List<String> ConnectionList; public DataContext(string Con = RuntimeDTO.DEFAULTDB) { HttpContext context = AppHttpContext.Current; if (context.Items[Con] == null) {

Does EF core compares value to include columns in update statement?

烈酒焚心 提交于 2020-06-28 05:25:17
问题 I have the following code var dbContext = Setup.ConfigureDBContext(); var wo = await dbContext.WorkOrders.Where(x => x.WorkOrderID == 88).SingleOrDefaultAsync(); var t = wo.Confidence; wo.ModifiedDateTime = DateTime.UtcNow; wo.Confidence = t; await dbContext.SaveChangesAsync(); in the above query i am assigning the same Confidence but changing the ModifiedDateTime EF generates the following SQL exec sp_executesql N'SET NOCOUNT ON; UPDATE [WorkOrders] SET [ModifiedDateTime] = @p0 WHERE

Accessing MS Graph from API on behalf of user currently signed in to separate web client

雨燕双飞 提交于 2020-06-28 05:16:45
问题 I am developing an API(ASP.NET Core) which is accessed via separately hosted web client(React), both hosted on azure as app services. Client app must have auth based on azure Ad(single tenant, preferably secured by azure auth based on aad). When the user signs in to client the API must have access to MS Graph on behalf of user. Obviously both resources must be secured, I have tried using azure auth based on AAD on both app services, but I couldn't get a token to MsGraph in this approach with

Accessing MS Graph from API on behalf of user currently signed in to separate web client

本小妞迷上赌 提交于 2020-06-28 05:16:08
问题 I am developing an API(ASP.NET Core) which is accessed via separately hosted web client(React), both hosted on azure as app services. Client app must have auth based on azure Ad(single tenant, preferably secured by azure auth based on aad). When the user signs in to client the API must have access to MS Graph on behalf of user. Obviously both resources must be secured, I have tried using azure auth based on AAD on both app services, but I couldn't get a token to MsGraph in this approach with

Get browser language in .AspNetCore2.0?

烈酒焚心 提交于 2020-06-25 07:56:11
问题 I am trying to get the default language from the browser and I use the following code to get it: var languages = HttpContext.Request.UserLanguages; Since the above is not supported with .NET Core 2 I tested with: var requestContext = Request.HttpContext.Features.Get<IRequestCultureFeature>(); However, it returns null. What is the correct way or alternative to get the language? 回答1: IRequestCultureFeature provides the first matched language, which is supported by your application. Declaration

System.InvalidOperationException: 'A path base can only be configured using IApplicationBuilder.UsePathBase().'

我是研究僧i 提交于 2020-06-22 17:46:03
问题 I have an ASP.Net Core 2 Solution running in Docker which is working fine on 1 machine the is running VS 2017 Professional but on another machine running VS 2017 Community I am getting the following error "System.InvalidOperationException: 'A path base can only be configured using IApplicationBuilder.UsePathBase().'" when I try and start or debug the solution using docker. If I start the solution with IIS Express it works fine. There is nothing special about my project: public class Program {

System.InvalidOperationException: 'A path base can only be configured using IApplicationBuilder.UsePathBase().'

我与影子孤独终老i 提交于 2020-06-22 17:45:49
问题 I have an ASP.Net Core 2 Solution running in Docker which is working fine on 1 machine the is running VS 2017 Professional but on another machine running VS 2017 Community I am getting the following error "System.InvalidOperationException: 'A path base can only be configured using IApplicationBuilder.UsePathBase().'" when I try and start or debug the solution using docker. If I start the solution with IIS Express it works fine. There is nothing special about my project: public class Program {

ASP.NET Core: Is it possible to use HttpClient to fetch a file and return directly?

烈酒焚心 提交于 2020-06-17 13:20:08
问题 I have an internal API that would fetch and return a fileresult. However, this API does not have any concept of authentication/role/permission checks and cannot be modified to do so. I would like to create an web API endpoint on an existing ASP.NET Core 2 Web API to do permission check, make a call to this internal API and return the fileresult back to a web client. Would it be possible to get the wrapper API endpoint to just pass whatever it fetches as a file result without having to