Questions tagged [asp.net-core-2.0]

1

votes
2

answer
779

Views

Antiforgery cookie in ASP.NET Core 2.0

I've been trying to understand exactly how the antiforgery works. What confuses me are the cookies which are created. To my understanding, you include the antiforgery token in your form and then you validate for that token when a request is made. This way if a third party websites posts to your webs...
Bojan
0

votes
0

answer
5

Views

How to connect UWP Desktop App with Backend RestApi?

Forgive me if it is not the right place to ask !! By the way, I have been working on .Net Core project having N-Layers architecture (Service Layer - WebApi 2, ORM - EF Core and for front end webapp (SPA using angular). Is it good idea to build UWP desktop app based on same backend by calling RestApi...
IP Kaal
0

votes
0

answer
3

Views

.NET Core Razor Template - Yield to content in partial

I've done this with other templating systems and I'm not sure how to do it with .NET Core Razor templates. I have a _Tabs partial and I want to pragmatically use different partials in each tab's content, ie a _Table or _Content partial. So for example, given the following two partials: // _Tabs.csht...
JDillon522
1

votes
1

answer
2.3k

Views

Sharing Cookies Between Two ASP.NET Core Applications

I'm using WsFederation in two separate ASP.NET Core projects. Each project has the following in Startup.cs services.AddAuthentication(sharedOptions => { sharedOptions.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; sharedOptions.DefaultSignInScheme = CookieAuthenticationDefaults.A...
Ryan Buening
1

votes
2

answer
356

Views

Byte Image Rotation in .Net Core

I've an IFormFile image file (from postman as form data), which I convert into byte array. Before converting it into byte array, I want to rotate it into its actual position (if user input image as 90°(right). I'm implementing web api in asp.net core 2.0. byte[] ImageBytes = Utils.ConvertFileToByt...
Amit Mishra
1

votes
2

answer
959

Views

DI ILogger with Serilog on Webapi 2 running Asp.Net Core 2

I am trying to integrate Serilog to my WebApi 2 with Asp.Net Core 2 (With MSSQLServer integration). I have added the nuget packages and then added the following to my public async void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) var log = new LoggerConf...
Matthew Flynn
1

votes
1

answer
873

Views

Using Serilog with .Net core and App Insights

I have used App insights directly for application logging before and I have seen that .Net core platform also creates trace events that goes to App insights. In a new .Net core API application, I'd like to use Serilog for application logging and App Insight for storing and visualizing the log event...
frosty
1

votes
1

answer
499

Views

Json Format for a TimeSpan that can be bound using Microsoft.Extensions.Configuration

In a project I need to configure some third party library via the Micorosoft.Extensions.Configuration. The library gives an options class and I used the configurationSection.Bind(optionsClassInstance) method to bind the values. It works well except the nested TimeSpan value. I can't figure out what...
monty
1

votes
1

answer
1.2k

Views

No authenticationScheme was specified, and there was no DefaultForbidScheme found with custom policy based authorization

I have a custom policy based authorization handler as defined below. Authentication is handled before the user hit this application so I only need authorization. I am getting the error: No authenticationScheme was specified, and there was no DefaultForbidScheme. If the authorization check succeeds...
Dennis Kiesel
1

votes
4

answer
362

Views

Validate query parameters without using a model in .netcore api

Is it possible to validate query parameters on an action without using a model? A lot of the calls in my API are one-offs and I don't see a point in making models for them if they will only be used one time. I saw the following article, which seemed like it was exactly what I needed, except I don't...
Austin Shaw
0

votes
1

answer
31

Views

Form in Layout: Razor Pages

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. Select Customer Vandalay Kramerica I know I can make a base PageModel and inherit from that on every page in order to resp...
Steven B.
3

votes
2

answer
172

Views

Using Selenium WebDriver in library csproj with .NET Core

I'm trying to put together a web-scraping app, using Selenium and .NET Core, but I'm having trouble getting my WebDriver exes to be found. I have one .csproj that will run the API for the project, which calls out to (amongst others) another .csproj that will handle the webscraping. All are in a sing...
Brondahl
-1

votes
5

answer
37

Views

C# Replace All Vowels in Generic List

How do I replace all vowels in list with a space? Following code does not seem to be working. List Instruments = new List(); Instruments.Add("cello"); Instruments.Add("guitar"); Instruments.Add("violin"); Instruments.Add("double bass"); string vowels = "a e i o u y"; Instruments.ForEach(w=>vowels =...
HardyWest
1

votes
2

answer
1.8k

Views

ASP.NET Core JWT and Claims

I have a question regarding JWT authentication in ASP.NET Core and Claims, because I don't know if I get everything correctly. When I create a JWT token in ASP.NET I add some Claims, some of which can be custom. What happens when the request with JWT token is sent from the client to API. How is User...
user1658223
1

votes
1

answer
1.1k

Views

.NET Core 2.0 Cookie Events OnRedirectToLogin

How can I apply a middleware to the OnRedirectToLogin event in Cookie options (so i can use dependency injection), OR how can I retrieve actionContext from RedirectContext? I have tried searching for documentation or examples, but it is hard to find, and I have not seen any examples explaining or de...
John Dover
1

votes
1

answer
72

Views

What is the best flow for Angular2 application and asp.net core 2.0 api

I am having a asp.net core 2.0 webapi and pure angular2 application. I am using Identityserver4 for implementing OpenId and OAuth2 for securing the webapi. Can anyone suggest what is the best flow to implement the angular2 client application? Thanks
Mukil Deepthi
1

votes
1

answer
410

Views

Why does SignalR convert the first letters of Dictionary keys to lower case when it serializes the dictionary and sends it to clients?

This is what is being sent from the server to the client: public class BattleHub : Hub { public override async Task OnConnectedAsync() { await Clients.Client(Context.ConnectionId).SendAsync("ConfigurationInfo", new Dictionary { { "WtF", "WtF" } }); await base.OnConnectedAsync(); } } This is what the...
gaazkam
1

votes
1

answer
827

Views

InvalidOperationException: Scheme already exists: Bearer

I recently resumed work on a project that had lain dormant for a year. It was using Angular on AspNet Core 1.1 and using an early version of OpenIddict 1.0. It was developed using VS2017. I updated VS2017 to the latest release (15.7.5) but the project would not compile and when I fixed the compilati...
Martin Horton
1

votes
1

answer
1.6k

Views

ASP.NET Core 2 - Missing content-type boundary

I'm trying to upload a file from a Angular client to my ASP.NET Core 2 WebAPI service. When I call the service, I get back an Internal Server Error. That's the error I'm getting: The component I'm using client-side is this one: ngx-uploader In my request options, i set them as you can see here: con...
moro91
0

votes
0

answer
3

Views

Serilog writes the logs twice

I'm using Serilog with Elasticsearch sink with the configurations like this: Log.Logger = new LoggerConfiguration() .MinimumLevel.Verbose() .MinimumLevel.Override("Microsoft", LogEventLevel.Verbose) .Enrich.FromLogContext() .Enrich.WithExceptionDetails() .Enrich.WithProperty("Application", "abc") .E...
mok
0

votes
0

answer
6

Views

EF Core - Table columns are automatically sorting

I have just added a few new models to my .NET Core application that is currently using EF code-first migrations. Previous models have migrated fine and in the order of my model properties, but things seem to have changed now. New models are sorted first by key values, then alphabetically. Here's an...
Mark
1

votes
0

answer
17

Views

.NETCore service.Configure appsettings with dynamic / JObject

My app reads the appsettings.json file in services startup.cs services.Configure(Configuration.GetSettings("somedata") After reading, I'm serving the data while service the JS files. My quiestion is - there's possible way to read in this way the appsettings and some of the poco will declared as dyna...
Someuser132
1

votes
1

answer
1.1k

Views

UseHangfireServer throws exception

I have a problem with my ASP.NET Boilerplate Core 2.0 application. I worked a lot on my application layer and now I want to try the code in the MVC project. But when I try to start the application I get the following error: System.InvalidOperationException: 'Unable to find the required services. Ple...
mg92
1

votes
0

answer
18

Views

ASP.NET Core 2.1 MVC: IModelValidator object is not called at model binding, why?

I want to implement custom model validator. I have used example code from Pro ASP .NET Core MVC book and it is not working. The custom model validator method is never called, yet model validation is successful. Action method signature: [HttpPost] public IActionResult EditPerson(Person model, int id...
J4ni
4

votes
4

answer
158

Views

The UPDATE statement conflicted with the FOREIGN KEY constraint in EF Core

We have 3 model classes: Host TournamentBatch TournamentBatchItem Host has many TournamentBatch. TournamentBatch has many TournamentBatchItem. In the TournamentBatch table will have FK Host. We did override for SaveChangesAsync in ApplicationDbContext to allow soft-delete as following: public o...
dcpartners
2

votes
1

answer
1.2k

Views

How can pass data from AuthorizationHandler to Controller in Asp.net core

I used a specific authorization policy for user log in, so created custom Authorization Handler. And I would like to display use a specific alert message if they failed the policy. I read the documentation and found that I could access AuthorizationFilterContext via casting AuthorizationHandlerConte...
ringord
2

votes
0

answer
342

Views

Multiple Angular 4 Areas in .NET Core 2 Project

I would like to have multiple Areas in my project that do share the same session. For instance I would like my main Area to be an SPA for Promoting my product, i would like a shop area with a separate SPA to sell stuff and i would like to have a third SPA where the users can manage their products....
RoXaS
0

votes
0

answer
6

Views

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

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...
winters0
2

votes
1

answer
1.6k

Views

web.config generation in Asp.Net Core 2

I know that Core 2 is moving away from the web.config and towards Json configuration. However, I have come across an issue where by my IIS 7 server has WebDav installed which is blocking HTTP PUT requests to my webapi. The following link has provided a working solution by removing WebDav; Remove Web...
Matthew Flynn
2

votes
0

answer
125

Views

What's the replacement for fuslogvw in .net core 2?

When encountering problems with resolving DLLs and assemblies in general with .Net fuslogvw gave you the ability to log the binding attempts so you could see exactly where it was looking and what was going on. There is a github issue discussing this, but it's not exactly got very much detail on what...
AndyJ
2

votes
2

answer
313

Views

Asp.net core 2.1 crashing due to model InverseProperty

My site is crashing on load with an extremely long unhandled exception in System.Reflection on the first call to the DbContext. Using ef-core 2.1 rc1 System.ArgumentNullException: Value cannot be null. Parameter name: type at System.Reflection.IntrospectionExtensions.GetTypeInfo(Type type) at Micros...
Hecatonchires
1

votes
2

answer
43

Views

ASP.NET Razor Pages - Conditional redirection

In one of my EF entities, I have a boolean field that indicates whether there is or not a maintainance going. Thus, I would like to reroute all my pages to a 503 error page only if this boolean is set to true. I could put the following piece of code in every Page: if (_context.SystemParameters.First...
Lovy
9

votes
0

answer
241

Views

.NET Core 2.0 Regex Timeout deadlocking

I have a .NET Core 2.0 application where I iterate over many files (600,000) of varying sizes (220GB total). I enumerate them using new DirectoryInfo(TargetPath) .EnumerateFiles("*.*", SearchOption.AllDirectories) .GetEnumerator() and iterate over them using Parallel.ForEach(contentList.GetConsuming...
James Nix
9

votes
0

answer
852

Views

How to integrate SAP Crystal Reports in asp.net core 2.0

I have created new architecture my ERP application by asp.net core 2.0 with angular js 4.0. Now I want to integrate crystal report my application. I am searching to integrate crystal report my application, but can not find any solution. How can I integrate that please tell me?
Sohag
9

votes
1

answer
696

Views

How to add Docker Support for Asp.Net Core 2.0 targeting full .Net Framework 4.7

I have an ASP.Net Core 2.0 application targeting .Net Framework 4.7 (full). I want to use Docker for it but VS 2017 15.5 does not allow me to Add Docker Support to it. (this is not supported jet). My question is: Is there any work-around this issue. If not, Can I still use docker with this project...
Luka
7

votes
1

answer
87

Views

No executable found matching command “dotnet-/app/Build\ClearPluginAssemblies.dll” Docker

I'm trying to run my ASP.NET Core 2.1 application with docker image. For that I have docker file with the following content: FROM microsoft/dotnet:2.1-sdk AS build WORKDIR /app # copy csproj and restore as distinct layers COPY . . RUN dotnet restore # copy everything else and build app COPY Presenta...
Div
4

votes
2

answer
2.9k

Views

Does .NET Core 2.0 have SFTP client? [closed]

Needing to use an SFTP client and looking to build it in a .NET Core 2.0 application. I was wondering if SFTP is already part of .NET standard 2.0 or will I need to use a 3rd party library for this, e.g. SSH.NET?
Los Morales
4

votes
2

answer
1.6k

Views

Asp.Net Core 2.0 ArgumentNullException: Value cannot be null. Parameter name: connectionString

I'm using ASP.NET Core 2.0, Visual Studio 2017 Enterprise, Version 15.5.4 and a local DB on my PC. I'm working for the first time with database first and I have encountered the following problem: unhandled exception occurred while processing the request. ArgumentNullException: Value cannot be null...
TAWH
1

votes
2

answer
558

Views

Override razor views in asp.net core razor pages

In asp.net core mvc, I had multiple locations specified for the views. so, if view was missing in one location, it gets fetched from the other location. I have a CMS with asp.net core mvc where controllers and views comes in a compiled library. If I don't want to use the view from the library, it's...
eadam
1

votes
1

answer
842

Views

Total hit/visitor counter in ASP.NET Core MVC Application

I would like to count total ever hit/visitor in my ASP.NET Core Web application. Whenever a new visitor will come to my site, total ever visitor value will be increased by one in database. In case of traditional ASP.NET MVC Application we can solve the problem by using Session variable in Session_St...
TanvirArjel

View additional questions