Questions tagged [.net-core]

21286 questions
1

votes
1

answer
134

Views

Problems with input masks in PartialViews - Asp.Net Core

I'm having trouble with input masks (bootstrap) on all screens. I found the following interesting: All my Views that are returned in the form of 'PartialView', the input masks do not work. For tests, when I create a View and a controller that returns a View, everything works correctly. This clearly...
Master JR
1

votes
1

answer
241

Views

How can I bind a SecureString or char[] parameter in .NET Core without using strings

When storing a string that is secret (eg a password or key) it is bad practice to use a System.String as strings are immutable and you cannot schedule garbage collection to remove them from memory. Microsoft recommends using SecureString to avoid this, where the content is also encrypted at rest. Se...
mrtimuk
1

votes
0

answer
80

Views

NHibernate many to one results in Operation is not supported

Hi I'm making a web app on .net core 2 using NHibernate. When I try to add many to one mapping in .xml I get this exception: fail: Microsoft.AspNetCore.Server.Kestrel[13] Connection id '0HLEFGR5COP4F', Request id '0HLEFGR5COP4F:00000002': An unhandled exception was thrown by the application. System....
Andrej Paučo
1

votes
1

answer
212

Views

Identity Server: Add claims to ClaimPrincipal with hybrid flow in MVC client

I am setting up an identity server and are having trouble understanding why I cannot access a newly added claim from my MVC site. I am using the quickstart sample no 5: (Link on github) with the following changes in the identity server: public static IEnumerable GetIdentityResources() { return new L...
Sebastian
1

votes
1

answer
482

Views

Populating and Accessing ClaimsIdentity in ASP.NET Core

I have a .NET Core 2.1 application where I have an authentication handler which I use to extract the value of a header. How do I add this value to my ClaimsIdentity, and how can I then access it from my controller? I have the following code which works on all my controller actions: public class Cust...
Robbie Mills
1

votes
1

answer
252

Views

Work with one dbContext and multiple connection string in EntityFramework and .net core dependency injection

I'm working in a project using EntityFramework Core and .net core 2.0, which I need to connect to multiple databases to get data to execute a cron, i injected DbContext.cs in startup.cs like above: services.AddDbContext(); I use it in my UnitOfWork.cs like this : public class UnitOfWork : IUni...
Boubakr Echieb
1

votes
0

answer
135

Views

Who insert Angular scripts in ASP.NET Core Angular template project

I created a new ASP.NET Core 2.1 Angular project. What is interesting is that there is index.html file inside ClientApp/src which is hosted as default page. I would like to know, which code triggers that index.html is served by default? In my old application from universal template Controllers an...
Makla
1

votes
1

answer
398

Views

IdentityServer4 - LogoutRequest.PostLogoutRedirectUri is null

I have an identity server project that I am working on that for some reason is setting the log out url as null. Using the 'BuildLogoutViewModelAsync(logoutId)' function found in the QuickStart, this line is returning null, but in the log the 'post_logout_redirect_uri' is set and is set correctly. v...
Rodney Pannell
1

votes
1

answer
1.1k

Views

Data Seeding by HasData not working on Visual Studio for Mac

I am getting some wonky behavior in Visual Studio for MacOS. I recently installed .NET Core 2.1 SDK and then upgraded a project from 2.0 to 2.1. I wanted to try out the new Data Seeding feature, which lets us seed data into an entity in an override of OnModelCreating method. modelBuilder.Entity().H...
Caffiene Monkey
1

votes
2

answer
307

Views

Assert that all properties but some are null

I have mapping methods, that maps model A to model B. I write unit tests for all of there. I want to somehow nicely handle situation when destination model has a lot of properties, but most of them are null. The test purpose is to test that some small number of properties were correctly mapped and o...
Martin Volek
1

votes
0

answer
69

Views

UrlHelper sometimes not returning the base url

I'm creating a .NET Core 2.1 web api and am experiencing issues with the UrlHelper. I use the Link method to determine links from one resource to another. Most of the time it is working just fine, but sometimes the resulting string lacks the base url. E.g.: Request 1: http://localhost:1234/api/books...
Geoffrey
1

votes
0

answer
46

Views

communication solution between azure app service and external program

I am building a website using ASP.NET MVC which gonna be deployed as Azure app service and I got another program which will interact with the website backend in real time and sends live data which needs to be displayed on the website as live data and it is bi-directional. We used message queues (Azu...
1

votes
0

answer
42

Views

Twitter:: External Callback-Not returning User’s Email address

I’m implementing external login in Asp.Net Web API application using Asp.Net core 2.0 with C#. While login using Twitter option, the application is redirecting to Twitter login page and after successful login, it is calling application’s callback method. In that method, we’re trying to get log...
Devendra Lodha
0

votes
1

answer
16

Views

Returning Status Codes from a class outside my Controller

I am trying to move logic that I do on all of my controllers into a class to follow the 'Do Not Repeat Yourself' principle. What I am struggling with is how to elegantly return an error code. Here are some examples of what I currently do within each controller: public class SomethingRequest { public...
thalacker
-1

votes
0

answer
13

Views

Catch multiple same type exception

Let's say I have a service that saves some objects to the db. I'm injecting the repo into it with DI. public class MyService { ... public async Task UpdateAll(IEnumerable objects) { foreach (var o in objects) { try { var tempObject = _injectedRepo.GetBySomeProperty(o.someProperty); if (tempObject !...
itVico
1

votes
0

answer
119

Views

How to host a combined angular 2 and dotnet core site on IIS

I'm building a website and wanted to use angular cli as frontend with .NET core 2 as a REST based backend service. So I created a new angular cli project and then created a webapi project using dotnet cli. I altered the angular.json file to make the output end up in the wwwroot folder of the WebApi...
Jimmy Byström
1

votes
0

answer
176

Views

Cache entire response to distributed cache (Redis)

I would like to cache an entire page to a distributed cache (specifically Redis) in an ASP.NET Core 2.1 MVC web app. When a user visits a page, the code in the action method and the view cshtml is executed, and a page is generated and sent to the user. I would like this page to get cached at the end...
Gary
1

votes
0

answer
331

Views

.Net Core: can't pass “geography” parameter to SQL Server stored procedure

I want to pass a parameter of SQL Server type geography to a stored procedure from .Net Core. So far, I have installed the System.Data.SqlClient and Microsoft.Spatial packages. Here is my code: using (SqlCommand cmd = new SqlCommand('myproc', connection)) { cmd.CommandType = CommandType.StoredProced...
A. Abrams
1

votes
0

answer
87

Views

Custom entities in Entity Framework

I'm using EF6 in my ASP.NET Core 2.0 I have Foo table as : Foo(ID,NAME) and Bar as Bar(ID,FOO_ID,TYPE) and a view just like this : Create View GETFooBar as select F.ID FOO_ID,F.NAME FOO_NAME,B.TYPE FOO_TYPE from Foo F join Bar B on F.ID = B.FOO_ID Can I do the following: public Class FooBar{ pub...
Arsalan
1

votes
4

answer
1.2k

Views

Gzip compression middleware not working in asp.net core 2.0

I am unable to get Gzip compression middleware to work in asp.net core 2.0 (or 2.1). I created a new project using the 'Blank' Web Application template and have the following code in Startup.cs: public void ConfigureServices(IServiceCollection services) { services.AddResponseCompression(); } // This...
Mark Miretsky
1

votes
1

answer
60

Views

GroupBy() not grouping correctly on List<T> property [duplicate]

This question already has an answer here: GroupBy on complex object (e.g. List) 3 answers I am trying to conditioanlly show a 'week list'(each day of a week) either showing all 5 days(Mon-Fri), or a single 'list item'(single list item represnting all days of week) based on if all items are the same...
Emo333
1

votes
1

answer
131

Views

Silent SSO login with Azure B2C and Open Id Connect in .NET Core MVC Application

We would like to implement functionality where user should be logged silently over Single sign-on. The user go to the application A and log into. Now he goes to the application B, which is using the same tenant as application A. At this moment to log into the application B, it is necessary by user t...
Anton Kalcik
1

votes
0

answer
127

Views

Best practice to deploy dacpac along asp.net core

I am trying out to figure what would be the best way to deploy a dacpac along an asp.net core application. Its an application that we provide to external users for download as an on-premise version to be installed in Azure, as such I am trying to make it a smooth as possible For now now I was plan...
MaxTheMax
1

votes
0

answer
355

Views

Print a form from asp.net core 2.0 for customer

We are searching for a solution for the following problem: We gather some data on our website via an HTML form. This data shall be used for creating a form which in the end shall be printed and physically signed. The data is stored in an MSSQL database. We don't know which is the best and easiest to...
mabota
1

votes
0

answer
328

Views

Update only some Model fields using generic Repository Entity Framework core

I have the Users Model follows: Model Users.cs [Key] [Column('cod')] public int Cod { get; set; } [Column('nome')] [StringLength(120)] public string Nome { get; set; } [Column('sobrenome')] [StringLength(80)] public string Sobrenome { get; set; } [Column('email')] [StringLength(60)] public string Em...
MariINova
1

votes
0

answer
70

Views

In Swashbuckle how to I filter a model based on status code

I have an api project where every method returns its response wrapped in an ApiResponse object. The class looks like this public class ApiResponse { [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public T Data { get; set; } [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] p...
user3599659
1

votes
0

answer
311

Views

How to use a custom domain with ASP.NET Core + Kestrel + Nginx

I have deployed my app to my virtual linux machine and everything works fine. I have redirect the domain to my ip and it works fine. The problem is when it redirects my domain to my linux machine ip the url shows my ip instead of the domain. Here's my Nginx file: server { listen 80; server_name mydo...
João Ribeiro
1

votes
0

answer
51

Views

Built-in strongly-typed validator in ASP.NET Core?

Currently my models implement IValidatableObject what means they aren't lean POCO's as I'd like them to be. If I'm using ValidationAttribute then I have to deal with object. If I'm using ActionFilterAttribute then I have to deal with context.ActionArguments collection. IS there a built-in strongly-t...
abatishchev
1

votes
0

answer
444

Views

How to Debug Angular 5 using ASP.NET Core in Visual Studio 2017

I created a ASP.NET Core project in Visual Studio 2017 following the VS available template with Angular 5. After that I've configured my tsconfig.json : And in Startup.cs I added Spa configuration: app.UseSpa(spa => { spa.Options.SourcePath = 'ClientApp'; if (env.IsDevelopment()) { spa.UseAngular...
Radu Olteanu
1

votes
1

answer
216

Views

Asp.Net MVC Core 2 web site with Wordpress in subdirectory

My hosting plan includes 1 site. I have installed a Asp.Net MVC Core 2 project on that site and it is working as designed. Now I would like install a blog on the same site in a subdirectory. The blog I am using is Wordpress. Wordpress is installed to a subdirectory on the Asp.Net MVC Core 2 site. Wh...
seisal
1

votes
1

answer
543

Views

ExceptionHandling Middleware vs filter aspnetcore webapi 2.1

I wonder if somebody can clarify this one .I find the usage confusing. Both links and video did NOT answer my question I am aware of links like asp.net core middleware vs filters and even a video about it However for the purpose of the webApi alone does it make sense to implement both? My understand...
developer9969
1

votes
0

answer
319

Views

Ambiguous column name error when Scaffold-DbContext EF Core

I follow the link to generate EF Core Db context into my project with Northwind database. I run bellow command for that Scaffold-DbContext 'database=NorthWind;server=localhost;user=sa;password=$pass$4;Trusted_Connection=True;' Microsoft.EntityFrameworkCore.SqlServer -OutputDir DbContext But its thro...
kuntal
1

votes
0

answer
44

Views

Define preprocessor variables in docker compose build

I want to make some P/Invoke calls from my ASP.Net Core application and for this I obviously need to determine which platform I'm running on. The project uses docker and linux containers so there might be only two possible platforms in my example: Linux (when running the project in docker) Windows...
TorbenJ
1

votes
0

answer
165

Views

dotnet core 2.0 - Logging Custom Events using LoggerMessage

I've been trying to replace the TelemetryClient in my code with the LoggerMessage pattern. (https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/loggermessage?view=aspnetcore-2.1) I could not find any way to log Custom Events in this pattern. Is there a way I can directly log Custom Eve...
Viktor KurDz
1

votes
0

answer
209

Views

ASP.NET Core: IsInRoleAsync and Authorize Attribute disagree

I am trying to implement basic authorization, but the Authorize attribute keeps rejecting my test admin account, even though IsInRoleAsync returns true. I'm pretty new to ASP.NET Core, so any help would be appreciated. This is building off of the ASP.NET Core Web App (MVC) template, if that helps. B...
Patrick Holley
1

votes
3

answer
127

Views

Using external javascript in .net core angular application

I am trying to use an external js library in my .net core angular app. I just don't know whats the standard way to reference a js file in an angular component. Where to place its reference and all that. I don't want any floating declarations. Any help. I see some solutions referring to angular cli f...
Jajan
1

votes
0

answer
87

Views

Why 3rd party Assembly references in class library project are needed to be added again in other projects referencing library project in C#?

Sorry for asking this naive question which is even difficult for me to describe. I have a classlibrary project say 'A' that has logic that I am referring in Project 'B' via Assembly reference (added the dll reference of Project 'A') which is basically an unit test project. Project 'A' uses some thir...
Vikas
1

votes
0

answer
53

Views

Deploying multiple .Net Core sites on Ubuntu server using Nginx

I followed these instructions to get one .Net Core website running on Ubuntu using Nginx: https://blog.cinlogic.com/2017/05/10/deploying-an-asp-net-core-web-application-to-ubuntu/ I created the following file in sites-available for my website 'mysite1' and it uses the default port 5000, but if I wan...
Primico
1

votes
0

answer
1.3k

Views

Is it still relevant to use Owin / Katana with ASP.NET Core (actual use case)?

Based on the answer here: How to explain Katana and OWIN in simple words and uses? Regarding the comment above, OWIN is not a framework. OWIN is a specification on how web servers and web applications should be built in order to decouple one from another and allow movement of ASP.NET applications to...
Ehouarn Perret
1

votes
1

answer
99

Views

How to set Environment Variables from server in Docker Compose?

Is there a way to force docker compose to assume environment variables from the underlying machine? Background: I decided to play around with Docker in my ASP.NET Core Web Application, so I used the Add Docker Support option in Visual Studio, which created a .dcproj (Docker Compose project). Prior t...
Alisson

View additional questions