asp.net-core-2.0

Insert character at nth position for each line in a text file

做~自己de王妃 提交于 2019-12-08 07:53:09
问题 I have text files, I need to add a space at the 8th character of each line in the text file. Text files have 1000+ multiple rows How would I conduct this? Original file example: 123456789012345.... abcdefghijklmno.... New file: 12345678 9012345 abcdefgh ijklmno Reading this article is helpful: Add a character on each line of a string Note: Length of text lines can be variable (not sure if it matters, one row can have 20 characters, next line may have 30 characters, etc. All text files are in

Form in Layout: Razor Pages

自闭症网瘾萝莉.ら 提交于 2019-12-08 07:17:24
问题 I have a select in a form in the Layout of my web app that needs to be accessible from every page. The form sets a session variable that is required to load data on every page. <form asp-page-handler="CustomerChange" method="post" class="navbar-form navbar-left"> <select name="Customer" id="Customer" class="form-control" onchange="this.form.submit()"> <option value="">Select Customer</option> <option value="Vand">Vandalay</option> <option value="Kram">Kramerica</option> </select> </form> I

connet to asp.net core signalR server from a javascript client

谁说我不能喝 提交于 2019-12-08 07:00:33
问题 I have asp.net core web api server that is streaming a signalr, And it works for asp.net client , I am trying to make a connection with the code showen beelow but it only connects to a none core servers it wouldnt work for the core servers. //the hub class in the server code [EnableCors("AllowAllOrigins")] [HubName("LogNotifierHub")] public class LogNotifierHub : Hub { //methods defined here } startup code for the routing : app.UseSignalR(routes => { routes.MapHub<LogNotifierHub>("

IdentityServer4 with asp.net core2.0 erron on AuthenticationOptions class

房东的猫 提交于 2019-12-08 06:43:00
问题 I am working on Identity Server 4 with asp.net core 2.0. In ConfigurationServices() method i added: app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions { Authority = "http://localhost:59391", RequireHttpsMetadata = false, ApiName = "api1" }); But it gives compile error that: Reference to type 'AuthenticationOptions' claims it is defined in 'Microsoft.AspNetCore.Authentication', but it could not be found. When i look into assembly code: namespace Microsoft.AspNetCore

Creating recursive method helper with Func<>

断了今生、忘了曾经 提交于 2019-12-08 06:03:46
问题 I have two method helper with theses signatures: @helper CreateNavigation(int parentId, int depthNavigation) @helper Navigation(int parentId, int depthNavigation) I have tried to convert it to a proper method for using in ASP.NET Core 2 . But I got an error in VS2017 IDE that is: 1- Use of unassigned local variable 'Navigation' 2- local variable 'Navigation' might not be initialized before accessing How can I fix it? @using Microsoft.AspNetCore.Html @using Microsoft.AspNetCore.Mvc.Razor

Asp.Net Core 2.0: Simple way to execute long running tasks and report progress?

喜欢而已 提交于 2019-12-08 05:20:48
问题 I have a page where the user can select multiple files and upload them. Once the files are buffered in the server, they are deserialized, and the object graphs are stored using Entity Framework Core 2 and SQL Server. All this happens within a controller action. The problem is that when the file is a little bit bigger, this collection of tasks can take about 5 minutes to complete, and because of that, I get a 502 error (probably a timeout). To solve this problem, I had the idea of reporting

Sonarqube vsts task exception on coverage for .net core 2 app

安稳与你 提交于 2019-12-08 05:04:41
问题 I believe this is more a bug report than a support question, but may be i can workaround it. I am building & testing a .net core 2 app: the vstest step is configured as below: A trx file and a binary .coverage files are produced. If Code coverage checkbox is disabled, build works. If enabled like in the picture it fails with the following error: SonarQube Scanner for MSBuild 3.0.2 Default properties file was found at C:\agent\_work\_tasks\SonarQubeScannerMsBuildBegin_15b84ca1-b62f-4a2a-a403

Web Api Core 2 distinguishing GETs

一曲冷凌霜 提交于 2019-12-08 03:54:50
问题 Why can't Web API Core 2 tell these apart? [HttpGet] public IEnumerable<string> Get() { return new string[] { "value1", "value2" }; } // GET api/values?name=dave [HttpGet] public string Get(string name) { return $"name is {name}"; } Here's what happens - Both http://localhost:65528/api/values and http://localhost:65528/api/values?name=dave cause the first Get() method to execute. This exact code works fine in Web Api 2. I know multiple ways of getting around this, but I don't know why it

Configure Column Options for Serilog Sinks MsSqlServer in AppSettings.json

♀尐吖头ヾ 提交于 2019-12-08 01:50:19
问题 I'm trying to determine if it's possible to configure the column options for serilog sink mssqlserver in the appsettings.json file for an ASP.Net Core 2 project. I create and configure the logger in the Program.cs file. public static IConfiguration Configuration { get; } = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) .AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE

One JWT token for many services

半世苍凉 提交于 2019-12-07 22:16:22
问题 I am facing the problem with JWT Authentication in ASP.Net Core. The scenario looks following: I have a ASP.NET Core Web API, let's call it 'API A'. It is resonsible for generating JWT Token to user who provide correct login/password, then token is generating. I have second ASP.NET Core Web Api, called 'API B' which returns some data from database. I would like to be able to use JWT token, generated by 'API A' to authorize access to data from 'API B'. Is it possible to achieve it by using