Questions

dotnet publish with /p:PublishProfile=?

I'm trying to call "dotnet publish" with a specific publish profile pubxml file as documented here : [https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/visual-studio-publish-profiles?view...

26 Oct at 13:15

Should I always add CancellationToken to my controller actions?

Is this a good practice to always add CancellationToken in my actions no matter if operation is long or not? I'm currently adding it to every action and I don't know if it's right or wrong. ``` [Api...

How do I make an ASP.NET Core void/Task action method return 204 No Content

How do I configure the response type of a `void`/`Task` action method to be `204 No Content` rather than `200 OK`? For example, consider a simple controller: ``` public class MyController : Controll...

14 May at 09:23

Should write complex query in Repository or Service layer?

I are planning migrate our data access layer to using repository pattern and unit of work. I do know repository will help me to change persistence store (database, collection...etc) and technology su...

Entity Framework Core mapping enum to tinyint in SQL Server throws exception on query

I get the following exception when I try to map an `enum` to `smallint` in `OnModelCreating`: > InvalidCastException: Unable to cast object of type 'System.Byte' to type 'System.Int32'. I want to do t...

6 May at 06:8

Set Accept header on ServiceStack JsonServiceClient

I am using the ServiceStack.JsonServiceClient to attempt to make a URL request with a custom value for the Accept header, but am unable to find a way to make the call. The service call is to retrieve...

11 May at 16:6

Why is a generic type constrained by 'Enum' failing to qualify as a 'struct' in C# 7.3?

If I have a generic interface with a `struct` constraint like this: ``` public interface IStruct<T> where T : struct { } ``` I can supply an enumeration as my type `T` like so, because an `enum` sa...

15 May at 15:36

Dynamic localized WPF application with resource files

Trying to make my wpf appliaction localized, I followed [this CodeProject tutorial](https://www.codeproject.com/Articles/299436/WPF-Localization-for-Dummies). I created my localized resource files (e...

11 May at 18:38

Disable system font size effect in my app

I don't want the system font size have any effect in my app. If I increase system font size in Android settings, the text in my app will be unreadable (i.e. too big). How can I solve it? I'm writing m...

6 May at 06:9

DotNet Core console app: An assembly specified in the application dependencies manifest

Im just trying to run a DotNet Core console app on a Windows Server 2012 R2 but I keep getting this error: The dll that is missing is inside the /publish folder... I used Dotnet publish with the co...

11 May at 09:54

.Net Blazor benefits over Angular , React or other javascript framework

What is the main feature of Microsoft's .Net Blazor? Can we use it in place of React or Angular? Will Blazor provide all the tools which are provided in Angular or React?

6 Sep at 13:2

How get a Span<byte> view of a struct without the unsafe keyword

How can a `Span<byte>` view (reinterpret cast) be created from a single struct value with no copying, no allocations, and keyword. I can currently only accomplish this using the unsafe keyword: `...

How to redirect on ASP.Net Core Razor Pages

I am using the new Razor Pages in ASP.Net core 2 Now I need to redirect I tried this, but the page does not redirect: ``` public class IndexModel : PageModel { public void OnGet() { ...

10 May at 21:43

VS Code CSC : error CS1617: Invalid option '7.3' for /langversion

I downloaded VS 2017 15.7, .NET Core 2.1.2 and Blazor to try it out. It wasn't working in VS 2017 properly and thought I would try through the dotnet cli and VS Code. Instead I was met with the follo...

Correlation failed in net.core / asp.net identity / openid connect

I getting this error when a Azure AD user login (I able to get the user´s claims after), im using a combination of OpenIdConnect, with asp.net Identity core over net.core 2.0 > The trace: > ![Co...

Require authentication for (almost) every request using ServiceStack

I am building an ERP using ServiceStack and have authentication wired in and working. However, I'd like to require authentication on basically every single route, DTO, or static page - except the Log...

9 May at 17:9

ServiceStack OrmLite - using String type for > and < expressions

I have the following POCO class, where Date is defined as a string and will always conform to the following format 'yyyyMMdd' ``` public class Price { [AutoIncrement] public int Id {get;set;}...

9 May at 13:41

Visual Studio 2017 Error --Cannot connect to runtime process

I am getting this error whenever I try to debug my project from visual studio. I tried adding these settings to launchSettings.json but still no difference. > "protocol": "legacy", "runtimeA...

4 Feb at 21:50

c# DateTime.Equals() not working properly

I am trying to compare two DateTime variables which are having the same values in it. But when I use Equals method it returns false which indicates "Not Equal". My code is : ``` DateTime date = Da...

9 May at 10:27

Export to Excel in ASP.Net Core 2.0

I used to export data to excel in asp.net mvc using below code ``` Response.AppendHeader("content-disposition", "attachment;filename=ExportedHtml.xls"); Response.Charset = ""; Response.Cache...

9 May at 06:56

How do you update sub-document in cosmos db

I am new to Cosmos Db and want to understand how to delete/upsert sub-documents within a document collection. If i have a document: `{ "Id": "1234", "Name": "foo", "Items": [ { "Id": "abcd", "Age": ...

9 May at 02:13

DPI Awareness - Unaware in one Release, System Aware in the Other

So we have this really odd issue. Our application is a C#/WinForms app. In our 6.0 release, our application is not DPI aware. In our 6.1 release it has suddenly become DPI aware. In the 6.0 release, i...

10 Feb at 06:17

User.Identity fluctuates between ClaimsIdentity and WindowsIdentity

I have an MVC site that allows logging in using both Forms login and Windows Authentication. I use a custom MembershipProvider that authenticated the users against Active Directory, the System.Web.Hel...

How to have different log types using Serilog and ElasticSearch

I am currently trying to change our system configuration to work with **Serilog** (*instead of working with FileBeat as a shipper to LogStash*) We are also working with the log **type** field (which i...

Create X509Certificate2 from PEM file in .NET Core

I want to create a X509Certificate2 object based on a PEM file. The problem is setting the PrivateKey property of X509Certificate2. I read [X509Certificate2.CreateFromCertFile() on .NET Core](https://...