Azure Function, returning status code + JSON, without defining return in every part of logic

I have an Azure Function 2.x that reside on a static class that looks like this ``` [FunctionName("Register")] public static async Task<IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "...

Force Servicestack to delimit fields when producing CSV

I'm using Servicestack to produce CSV. The data contains mobile (cell) phone numbers. These start with a leading zero e.g. 04053333888. My problem is the consumers open this file in Excel, which trunc...

24 Feb at 22:53

Cannot edit in read-only editor VS Code

I am using Visual Studio Code V 1.31.1. I used an input function but I can't write an input in output panel it shows this error > Cannot edit in read-only editor. Please help me solve this problem. ...

24 Feb at 20:54

ServiceStack: Upgrade to 5.4.1 gives me ReflectionTypeLoadException on ServiceStack.Common

I was running ServiceStack 5.2.0, until I upgraded due [to this answer](https://stackoverflow.com/questions/54840831/servicestack-accessing-the-irequest-in-the-service-returns-null). After doing that,...

13 Sep at 22:38

Disable code formatting for specific block of code in Visual Studio

How can I for a specific block of code in (C# 7)? I have this method: ``` public CarViewModel(ICarsRepo carsRepo) { ... Manufacturers = ToSelectList<Manufacturer>(); Categories = ToSele...

1 Dec at 00:39

When do we need IOptions?

I am learning DI in .Net Core and I do not get the idea about the benefit of using `IOptions`. Why do we need `IOptions` if we can do without it? # With IOptions ``` interface IService { vo...

23 Feb at 17:18

How do I set & fetch Environment variable in AWS Lambda Project in C#

I have created `AWS Lambda Project` in `C#` (NOT Serverless Application) [](https://i.stack.imgur.com/p3pJO.png) I have defined a Environment variable in `aws-lambda-tools-defaults.json` as below `...

ServiceStack: Accessing the IRequest in the Service returns null

I am using [Servicestack](https://servicestack.net/). I have a base class for my Services, like so: ``` public abstract class ServiceHandlerBase : Service ``` and then some methods and properties i...

26 Feb at 21:45

Unable to resolve service for type 'Microsoft.AspNetCore.Mvc.IUrlHelper' while attempting to activate

I am trying to separate code from controller to service that I created. What I did is to create a User Service with interface IUserService. Moved RegisterUser code from directly controller to UserSer...

23 Feb at 08:27

How to Add a new Name Value Pair to an Incoming Request's Headers in ServiceStack 5.0?

I have a custom Plugin I wrote which I add to the Plugins list inside the Configure method of AppHost. I'm using this plugin to authenticate the internal users that came through Postman. Get their cr...

22 Feb at 21:35

Can Servicestack Deserialize XML without namespaces

I'm familiar with these two methods: ``` var newDataSet = XmlSerializer.DeserializeFromString<NEWDATASET>(xmlDoc.OuterXml); var newDataSet = xmlDoc.OuterXml.FromXml<NEWDATASET>(); ``` But they both...

Why Extra Copy in List<T>.AddRange(IEnumerable<T>)?

I'm looking at the open source code for [System.Collections.Generic.List<T>](https://referencesource.microsoft.com/#mscorlib/system/collections/generic/list.cs,245). The `AddRange(IEnumerable<T>)` me...

Dotnet publish not publishing DLL to publish directory

I want to publish my self contained .NET Core (2.2) application, however one specific NuGet package (`Microsoft.Management.Infrastructure`) is never published to the `publish` folder (as in the .dll f...

22 Feb at 17:51

Working with Anaconda in Visual Studio Code

I am getting a bit confused here, the latest Anaconda Distribution, 2018.12 at time of writing comes with an option to install Microsoft Visual Studio Code, which is great. When launching VSC and aft...

typeof generic and casted type

Let's say we have generic method: ``` public void GenericMethod<T>(T item) { var typeOf = typeof(T); var getType = item.GetType(); } ``` And we are invoking it with the following parameters...

22 Feb at 12:59

How to store all ctor parameters in fields

I'm learning C# and a thought came up when coding. Is it possible to automaticly store parameters from a constructor to the fields in a simple way without having to write `this.var = var` on every var...

22 Feb at 10:23

ServiceStack: Multithreading using AppSelfHostBase - can it handle concurrent calls?

I read [this SO post](https://stackoverflow.com/questions/14238680/how-does-servicestack-handle-concurrent-calls), but it wasnt immediately clear to me how the AppSelfHostBase is handling the same que...

22 Feb at 09:15

Connect to On Prem SQL server from Azure Web app

I have .Net application at on prim. I want to host it at Azure but don't want to move database. I publish the application on Azure but it is not able to connect to on prim database. SQL server is in...

FirstOrDefaultAsync() & SingleOrDefaultAsync() vs FindAsync() EFCore

We have 3 different approaches to get single items from EFCore they are `FirstOrDefaultAsync()`, `SingleOrDefaultAsync()` (including its versions with not default value returned, also we have `FindAs...

4 Sep at 14:2

How to turn set Cache-Control using ServiceStack?

I want to turn off caching for my HTTP responses. Here's my code: `public class CacheControlHeaderAttribute : ResponseFilterAttribute { public override void Execute(IRequest req, IResponse res, obj...

21 Feb at 21:10

SMTP settings in appSettings.json in dotnet core 2.0

In Asp.net, I can normally send emails using the following code: ``` using (var smtp = new SmtpClient()) { await smtp.SendMailAsync(mailMessage); } ``` With the smtp settings being provided in ...

21 Feb at 09:57

Startup.cs vs Program.cs in ASP.NET Core 2

I looked through the documentation on the Microsoft website and there are two places where we can set up the configuration. We can do it either in or However, has the same methods that are availab...

2 Mar at 13:5

set global timezone in .net core

In .Net Core 2 - Is there a way to set the application's timezone globally so that whenever I request for `DateTime.Now` I'll get the current time for a timezone I want (lets say GMT+3) instead of th...

Override visibility time for queued message [ServiceStack]

For long-running message-based requests, we can set the visibility timeout at the queue level, but there doesn't appear to be a way to override it at the message level. I'd like to be able to extend ...

Access to fetch at *** from origin *** has been blocked by CORS policy: No 'Access-Control-Allow-Origin'

I have error > Access to fetch at '[http://localhost:5000/admin/authenticate](http://localhost:5000/admin/authenticate)' from origin '[http://localhost:3000](http://localhost:3000)' has been blocked...

14 Dec at 15:40