Proper way of testing ASP.NET Core IMemoryCache

I'm writing a simple test case that tests that my controller calls the cache before calling my service. I'm using xUnit and Moq for the task. I'm facing an issue because `GetOrCreateAsync<T>` is an e...

Servicestack object parameter not getting passed to service with Swagger-UI

My service model: ``` [Route("/customer/{CustomerId}/creditcardtoken/{CanLookup}", "POST")] public class CreditCardToken : IReturn<CreditCardTokenResponse> { [ApiMember(ParameterType = "path", Da...

18 Nov at 18:43

Pattern match variable scope

In the [Roslyn Pattern Matching spec](https://github.com/dotnet/roslyn/blob/features/patterns/docs/features/patterns.md#scope-of-pattern-variables) it states that: > The scope of a pattern variable i...

18 Nov at 15:31

Servicestack Ormlite multi-column constraint fails where constraint includes Enum

I am using ServiceStack.Ormlite, and also make heavy use of the automatic handling of enums whereby they are stored in the db as strings but retrieved and parsed nicely back into Enums on retrieval, s...

Which exceptions can HttpClient throw?

I am using [HttpClient](https://msdn.microsoft.com/de-de/library/system.net.http.httpclient(v=vs.118).aspx) in a xamarin forms project The class is documented, but I can not find any documentation ab...

18 Nov at 13:6

VS 2015 SSIS Script Tasks cannot be debugged

Just spent hours pulling my hair trying to work out why my ssis Script Component was not breaking into debugger on hitting a breakpoint. I searched the web and fund 64 bit setting (Project -> Properie...

30 Oct at 20:44

What is the difference between "x is null" and "x == null"?

In C# 7, we can use ``` if (x is null) return; ``` instead of ``` if (x == null) return; ``` Are there any advantages to using the new way (former example) over the old way? Are the semantics any di...

21 Oct at 02:28

Reference operators in XML documentation

I would like to reference an operator in a `<see cref="..." />` [XML documentation](https://msdn.microsoft.com/en-us/library/b2s063f7.aspx) tag, but I can't seem to find any hints on how to do it. The...

20 Jun at 09:12

Load* POCO references using OrmLite and SQL

I have a few questions about ServiceStack.OrmLite's POCO reference capabilities. 1. When using the Load*() API to fetch POCO with references, does it internally generate & run a single SQL query (wi...

18 Nov at 08:25

How can I manually check the url authorization in MVC5?

To restrict the access to an web app, an Administrator is able to set the url authorization of users and groups via the IIS-Manager: [](https://i.stack.imgur.com/jJFvf.png) The IIS-Manager store...

ASP.NET Core Select Helper Throws Object Reference not set to an instance of an Object

I've created an ASP.NET Core web application that uses Entity Framework Core to read from my existing database. I want to populate a select control with a list of FacilityNames in a view to create a ...

Unrecognized C# syntax

Let's say we have: ``` class Foo { public int IntPropertyInFoo { get; set; } public Bar BarPropertyInA { get; set; } } class Bar { public string StringPropertyInBar { get; set; } } ``` ...

17 Nov at 20:41

Prompt file download

I have a link on my page on click of which I am trying to generate a PDF document and then show the "Open - Save" prompt on the browser. My HTML (reactjs component) has the below code where `onclick`...

SqlConnection.Open vs SqlConnection.OpenAsync - what's different between the two beyond the obvious?

This boils down to why does changing just SqlConnection.Open() to await SqlConnection.OpenAsync() within asynchronous code result in strongly different behavior. What's the difference between a SqlC...

17 Nov at 20:40

Update claims in ClaimsPrincipal

I am using Adal with Azure Active Directory and I need to add extra claims via custom OwinMiddleware. When I add claims to this principal, I am able to access them in the current request. But after a ...

18 Nov at 15:27

AutoMapper - What's difference between Condition and PreCondition

Suppose a mapping using AutoMapper like bellow: ``` mapItem.ForMember(to => to.SomeProperty, from => { from.Condition(x => ((FromType)x.SourceValue).OtherProperty == "something"); from.MapFro...

14 Feb at 13:10

How to add Persistent Listener to Button.onClick event in Unity Editor Script

I am trying to do a simple thing: 1. Create a new GameObject 2. Add a Button component to the GameObject. 3. Add a persistent Listener to Button's OnClick event. The method I am trying to register ...

11 Sep at 17:48

Register Service at Runtime via DI?

I am using ASP.NET Core and want to add a service to the IServiceProvider at runtime, so it can be used across the application via DI. For instance, a simple example would be that the user goes to th...

How to stop Chrome's Select a certificate window?

I'm working on a Selenium project and the system I need to test is using an SSL certificate. Every time when I try to login we are getting this "Select a certificate" window which we cannot handle wit...

What is the difference between Microsoft.Spatial and System.Spatial libraries

I would like to know what is the difference between two spatial libraries - Microsoft.Spatial and System.Spatial? When I'm looking into the code of those two I see almost the same classes. Both has f...

How do I declare a C# anonymous type without creating an instance of it?

Is there a better way that can I declare an anonymous type, without resorting to create an instance of it? ``` var hashSet = new [] { new { Name = (string)null } }.Take(0).ToHashSet(); // HashSet<T>...

17 Nov at 11:30

Performance: .Join vs .Contains - Linq to Entities

I am using Linq to entities to query the database to get the list of int for further processing. I have two ways to get the list as below: ``` List<int> lstBizIds = new List<int>() { 1, 2, 3, 4, 5 ...

Type or namespace name Mock<> could not be found Entity Framework 6

I am trying to mock my `DbContext` for writing my unit tests. I saw a tutorial, and tried to do it like the following: ``` [TestMethod] public void MyFirstTest() { var mockSet = new Mock<DbSet<V...

ASP.NET Core Authorize attribute not working with JWT

I want to implement JWT-based security in ASP.Net Core. All I want it to do, for now, is to read bearer tokens in the `Authorization` header and validate them against my criteria. I don't need (and do...

29 Mar at 05:38

Service Stack Swagger 2.0 and Azure Api Management Import

I am trying to import my Service Stack swagger.json into an Azure Api Management instance. Its failing with "One or more fields contain incorrect values: Parsing error(s): The Swagger version specifie...