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
How can I rename default session cookie names in servicestack
ServiceStack has the default cookie names "ss-id" "ss-pid" and "ss-opt" defined in SessionFeature.cs Is there a way to change the default names to something else? The configuration code in HostConfi...
- Modified
- 21 Oct at 13:49
Invalid zip file after creating it with System.IO.Compression
I'm trying to create a zip file that contains one or more files. I'm using the .NET framework 4.5 and more specifically System.IO.Compression namespace. The objective is to allow a user to download a ...
- Modified
- 21 Oct at 11:21
Service reference - why reuse types in referenced assemblies
I'm following instructions to add a service reference to my project and, by default, the "reuse types in referenced assemblies" is ticked. If I leave it ticked, I get ambiguous warnings on controls l...
- Modified
- 21 Oct at 11:4
Asp.net core model doesn't bind from form
I catch post request from 3rd-side static page (generated by Adobe Muse) and handle it with MVC action. ``` <form method="post" enctype="multipart/form-data"> <input type="text" name="Name"> .....
- Modified
- 21 Oct at 09:11
Use "Optional, DefaultParameterValue" attribute, or not?
Is there any difference between using `Optional` and `DefaultParameterValue` attributes and not using them? ``` public void Test1([Optional, DefaultParameterValue("param1")] string p1, [Optional, Def...
- Modified
- 18 Aug at 20:41
Detecting that a method is called without a lock
Is there any way to detect that a certain method in my code is called without using any lock in any of the methods below in the call stack? The goal is to debug a faulty application and find out if ce...
- Modified
- 21 Oct at 07:21
MongoDB and C# Find()
I have the below code and I am new to mongodb, I need help in finding an specific element in the collection. ``` using MongoDB.Bson; using MongoDB.Driver; namespace mongo_console { public class U...
- Modified
- 20 Oct at 23:0
Does calling View Model methods in Code Behind events break the MVVM?
I wonder if that would break the MVVM pattern and, if so, why and why is it so bad? ``` <Button Click="Button_Click" /> ``` ``` private void Button_Click(object sender, RoutedEventArgs e) { ...