asp.net-core-mvc

How to check if a section in MVC Core configuration file exist?

我只是一个虾纸丫 提交于 2021-02-10 12:49:07
问题 How can I check if a specific section in loaded ASP.NET Core configuration file exist? I have a JSON configuration file that I load it in Startup class via ConfigurationBuilder.AddJsonFile method. This JSON file is an array with this layout: { "Url": "", "Regex": [ "", "" ], "Keys": { "Title": "", "Description": "", "Keywords": [ "" ] } } But some of them doesn't have Keys . I tried to check return type of section.GetSection("Keys") against null , But it doesn't return null even if Keys

Pass through the HTTP response to the client in MVC 6

萝らか妹 提交于 2021-02-10 10:54:25
问题 I am new to Web API and HTTP. I am using the MVC 6 (beta version). I have a proxy service (Web API) which has a POST method to get response from another service with XML content returned. I need to return the response content to the client since the client can't call the service directly. // In my proxy service public HttpResponseMessage Post(String content) { using ( HttpClient client = new HttpClient() ) { ....... HttpResponseMessage response = client.PostAsync(uri, content).Result; // I

ASP.NET Core stored procedure not working in loop

浪尽此生 提交于 2021-02-10 08:16:51
问题 I want to use a stored procedure for DB query, it works for a single query, but in loop, it executes like in first loop iteration. var getAutoResults = new List<List<Karat_getAutoData_Result>>(); foreach (var elem in meas) { getAutoResults.Add(await _context.KaratGetAutoDataResults .FromSql($"dbo.Karat_getAutoData @MeasurementId = {elem.MeasurementId}, @CalcRequestId = {null}") .ToListAsync()); } After this I get N times the same results, but all ids are different. 回答1: I can resolve it only

ASP.NET Core stored procedure not working in loop

Deadly 提交于 2021-02-10 08:14:56
问题 I want to use a stored procedure for DB query, it works for a single query, but in loop, it executes like in first loop iteration. var getAutoResults = new List<List<Karat_getAutoData_Result>>(); foreach (var elem in meas) { getAutoResults.Add(await _context.KaratGetAutoDataResults .FromSql($"dbo.Karat_getAutoData @MeasurementId = {elem.MeasurementId}, @CalcRequestId = {null}") .ToListAsync()); } After this I get N times the same results, but all ids are different. 回答1: I can resolve it only

ASP.NET Core stored procedure not working in loop

寵の児 提交于 2021-02-10 08:14:25
问题 I want to use a stored procedure for DB query, it works for a single query, but in loop, it executes like in first loop iteration. var getAutoResults = new List<List<Karat_getAutoData_Result>>(); foreach (var elem in meas) { getAutoResults.Add(await _context.KaratGetAutoDataResults .FromSql($"dbo.Karat_getAutoData @MeasurementId = {elem.MeasurementId}, @CalcRequestId = {null}") .ToListAsync()); } After this I get N times the same results, but all ids are different. 回答1: I can resolve it only

ASP.NET Core stored procedure not working in loop

旧街凉风 提交于 2021-02-10 08:13:14
问题 I want to use a stored procedure for DB query, it works for a single query, but in loop, it executes like in first loop iteration. var getAutoResults = new List<List<Karat_getAutoData_Result>>(); foreach (var elem in meas) { getAutoResults.Add(await _context.KaratGetAutoDataResults .FromSql($"dbo.Karat_getAutoData @MeasurementId = {elem.MeasurementId}, @CalcRequestId = {null}") .ToListAsync()); } After this I get N times the same results, but all ids are different. 回答1: I can resolve it only

ASP.NET Core stored procedure not working in loop

醉酒当歌 提交于 2021-02-10 08:10:48
问题 I want to use a stored procedure for DB query, it works for a single query, but in loop, it executes like in first loop iteration. var getAutoResults = new List<List<Karat_getAutoData_Result>>(); foreach (var elem in meas) { getAutoResults.Add(await _context.KaratGetAutoDataResults .FromSql($"dbo.Karat_getAutoData @MeasurementId = {elem.MeasurementId}, @CalcRequestId = {null}") .ToListAsync()); } After this I get N times the same results, but all ids are different. 回答1: I can resolve it only

ASP.NET Core stored procedure not working in loop

Deadly 提交于 2021-02-10 08:10:41
问题 I want to use a stored procedure for DB query, it works for a single query, but in loop, it executes like in first loop iteration. var getAutoResults = new List<List<Karat_getAutoData_Result>>(); foreach (var elem in meas) { getAutoResults.Add(await _context.KaratGetAutoDataResults .FromSql($"dbo.Karat_getAutoData @MeasurementId = {elem.MeasurementId}, @CalcRequestId = {null}") .ToListAsync()); } After this I get N times the same results, but all ids are different. 回答1: I can resolve it only

Mobile Specific Views / Device Detection

放肆的年华 提交于 2021-02-08 13:53:12
问题 In the .NET Core docs there is a page titled "Building Mobile Specific Views" but is under construction: https://docs.asp.net/en/latest/mvc/views/mobile.html. Does anyone have some insight on building mobile views or successfully doing device detection? 回答1: Serving specific views based on the browser's user-agent is an outdated concept as it do not sufficiently says much about the capabilities of the device. For example, iPhone and iPad come in different screen sizes and even mobile browsers

ASP.NET MVC Core Tag Helper Issue

*爱你&永不变心* 提交于 2021-02-08 10:25:18
问题 I am having an issue using tag helpers in a form element. When I choose the "GET" HTTP method, the parameter for my Edit method in my Item controller won't get filled by the "hello" argument. However, when I choose the "POST" HTTP method, the parameter is filled correctly with "hello". Why is this happening? <form asp-controller="Item" asp-action="Edit" asp-route-item="hello" method="get"> <input type="submit" /> </form> And here is the controller: [HttpGet] [HttpPost] public IActionResult