Dynamically calling method and class name
I have some cases where I have to call method names from class names. ``` string scenario1 = "MockScenario1"; string scenario2 = "MockScenario2"; MockScenario1.GetInfo(); MockScenario2.GetInfo(); ``...
MSBuild conflict between mscorlib 4.x and mscorlib 2.x
I was investigating a build failure recently and saw a warning about conflicts between assemblies. I dug deeper and MSBuild told me this: > There was a conflict between "mscorlib, Version=4.0.0.0, C...
PayPal in ASP.NET Core
How do I integrate with the `PayPal API` in an `ASP.NET Core` app? I have tried various libraries but none of them are compatible with `ASP.NET Core`... how do I do it?
- Modified
- 25 Oct at 08:10
How to mock HttpContext.User
I am working on a Asp.net MVC 5 project and I am trying to setup a mock to return a custom principal within a controller. I have search and tried different approach suggested but none of them works. ...
- Modified
- 25 Oct at 08:8
.NET Core get connection string from appsettings.json
I develop a simple web app and, in the future, I want to do it as multi-tenancy. So I want to write the connection string straight into `OnConfiguring` method: ``` public class ApplicationContext : ...
- Modified
- 24 Oct at 12:49
How do I insert data when the primary key column is not an identity column?
I'm trying to insert data using Dapper.Contrib, in a table where the primary key column is not an identity column. The database table is created with this script: ``` begin transaction create table...
- Modified
- 24 Oct at 11:54
Redirect to login when unauthorized in ASP.NET Core
In the previous ASP.NET MVC, there was an option to redirect to the login action, if the user was not authenticated. I need the same thing with ASP.NET Core, so I: 1. created a ASP.NET Core project...
- Modified
- 24 Oct at 12:50
Why detailed error message is not passed to HttpClient?
I am using the default Web Api controller that is auto generated. I am testing the validation and error handling in the client side. But somehow I have realised that the detail error message is not pa...
- Modified
- 24 Oct at 10:23
How to use HttpClient without async
Hello I'm following to [this guide](https://learn.microsoft.com/en-us/aspnet/web-api/overview/advanced/calling-a-web-api-from-a-net-client) ``` static async Task<Product> GetProductAsync(string path)...
- Modified
- 9 Aug at 05:12
How to add Roles to Windows Authentication in ASP.NET Core
I created an asp.net core project in visual studio 2015 with windows authentication. I can't figure out how to add roles to the Identity. I have a table with usernames for the windows account. And wh...
- Modified
- 23 Oct at 20:8
ASP.NET Core Response.End()?
I am trying to write a piece of middleware to keep certain client routes from being processed on the server. I looked at a lot of custom middleware classes that would short-circuit the response with ...
- Modified
- 23 Oct at 18:52
Largest sum of upper-left quadrant of matrix that can be formed by reversing rows and columns
I'm working on a HackerRank problem that's finding the largest sum of the elements in upper-left quadrant of a 2N x 2N matrix after reversing rows and columns. For example, if the matrix is ``` M = [...
- Modified
- 23 Oct at 17:7
Where to call .AsParallel() in a LINQ query
# The question In a LINQ query I can correctly (as in: the compiler won't complain) call .AsParallel() like this: ``` (from l in list.AsParallel() where <some_clause> select l).ToList(); ``` or...
- Modified
- 23 Oct at 16:54
Is there any danger in using ConfigureAwait(false) in WebApi or MVC controllers?
Say I have two scenarios: ``` [System.Web.Http.HttpPost] [System.Web.Http.AllowAnonymous] [Route("api/registerMobile")] public async Task<HttpResponseMessage> RegisterMobile(RegisterMod...
- Modified
- 23 May at 11:54
The instance of entity type 'BookLoan' cannot be tracked
I'm trying to update an entity and I've run into the following error: > InvalidOperationException: The instance of entity type 'BookLoan' cannot be tracked because another instance of this type wi...
- Modified
- 23 Oct at 00:33
Retrieve IAuthRepository from ServiceStackController
I've upgraded an old ASP.Net Mvc project that uses Servicestack from 4.0.40 to 4.5 but I've seen that when calling the base.HasRole I've to pass an IAuthRepository, I was wondering if there's a way to...
- Modified
- 22 Oct at 19:28
How to connect to a Unix Domain Socket in .NET Core in C#
I've created a unix socket in .NET Core on Linux (Ubuntu 16.04): ``` var unixSocket = "/var/run/mysqld/mysqld.sock"; var socket = new Socket(AddressFamily.Unix, SocketType.Stream, ProtocolType.IP); `...
Unable to deserialize service response when using servicestack MsgPack client
Am getting below error when trying to deserialize the response from the service while using servicestack MsgPackServiceClient. Exception: {"Cannot deserialize member 'test1' of type 'System.Int32'."...
- Modified
- 22 Oct at 09:7
HttpClient in using statement
hi i read this article [You're using HttpClient wrong and it is destabilizing your software](http://aspnetmonsters.com/2016/08/2016-08-27-httpclientwrong/) the article is suggesting these 2 1. Make ...
- Modified
- 22 Oct at 00:30
Compiler generates infinite loop after finally block when
I'm using standard VS2015 compiler targeted for .Net 4.6.2. Compilator emits infinite loop after failing finally block. Some examples: Debug: ``` IL_0000: nop .try { IL_0001: nop IL_0002: ...
Reflection GetValue of static field with circular dependency returns null
With these classes: ``` public class MainType { public static readonly MainType One = new MainType(); public static readonly MainType Two = SubType.Two; } public sealed class SubType : MainT...
- Modified
- 2 Nov at 02:34
EF Core Include on multiple sub-level collections
Consider this aggregate root... class Contact { ICollection Addresses { get; set; } ICollection Items { get; set; } ICollection Events { get; set; } } ...which I have used like so......
- Modified
- 6 May at 07:24
Thread aborted exceptions in wcf service
I have a WCF service (built in .NET framework 3.5) hosted on IIS 6.0. The flow of the code is as follows 1. Client (which is another web service) calls the WCF service 2. WCF services invokes a thr...
- Modified
- 26 Oct at 14:5