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...

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"> .....

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...

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...

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...

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) { ...

20 Oct at 17:24

Servicestack request no quotes in json body

Can someone tell me why do I see quotes in my request body in Fiddler and my servicestack request field has none? ``` POST http://10.255.1.180:8087/testvariables/new/ HTTP/1.1 Host: 10.255.1.180:8087...

21 Oct at 11:59

Asp.net core default route

Simplified `Startup` code: ``` public void ConfigureServices(IServiceCollection services) { services.AddMvc(); } public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app...

21 Oct at 08:3

Entity Framework Include performance

I have been looking at Entity Framework performance, particularly around the use of and the time taken to both generate and execute the various queries. I am going to detail changes I have made, but ...

(ServiceStack) Location of business logic in a message based architecture

What is the best practice for placing business logic in message based design? Im using servicestack for building my api. [The wiki](https://github.com/ServiceStack/ServiceStack/wiki/Authentication-and...

20 Jun at 09:12

User.IsInRole returns nothing in ASP.NET Core (Repository Pattern implemented)

I have an ASP.NET Core (Full .NET Framework) application with the following configuration: Startup.cs ``` public void ConfigureServices(IServiceCollection services) { // Add framework services. ...

20 Oct at 10:9

How to handle exceptions in Parallel.ForEach?

I have a `Parallel.ForEach` loop in my code and I am wondering how to handle exceptions. Should I catch and handle(e.g write to log) exceptions inside the loop or should I catch aggregate exception ou...

How to handle errors differently for (or distinguish between) API calls and MVC (views) calls in ASP.NET Core

In my applications based on ordinary MVC and WebApi I had two different error handling routes. If an error occurred during WebApi call, I would intercept it (using standard web api options) and retu...

How to get a Console output in ASP.NET Core with IIS Express

ASP.Net Core documentation [here](https://docs.asp.net/en/latest/fundamentals/logging.html) has a nice console logging output like in the picture below with colors for various LogLevels. I have now cr...

29 Aug at 00:42

Calling another Web API controller directly from inside another Web API controller

Given a controller `Proxy` and an action of `GetInformation`. I want to be able to call the method `GetInformation` of the `Users` controller. Both the WebAPI controllers are in the same project but...

20 Oct at 00:7

EF - Cannot apply operator '==' to operands of type 'TId' and 'TId'

I have this generic class, which uses Entity Framework 6.x. ``` public class GenericRepository<TEntity, TId> where TEntity, class, IIdentifyable<TId> { public virtual TEntity GetById(TId id) ...

23 May at 11:48

Visual Studio - suppress certain "Exception thrown" messages

Can you hide "Exception thrown" messages in output for certain methods (certain code areas)? I use HttpWebRequest for server communication. I periodically check if the server is available (a few times...

7 Jun at 10:51

Convert Razor String Variable to Javascript String Variable in MVC

I am trying to pass my string variable (even boolean) on my cshtml view to my javascript section. I can successfully pass the value from razor section to javascript if its integer. But what I want to ...

Using ServiceStack OrmLite to delete rows with condition in other table

I have the following tables in the database: ``` Table C Table B Table A ------- ------- ------- Id Id Id BId AId ``` The BId column is a foreign key to TableB. A...

Entity Framework Core - Lazy Loading

Bowing to my Visual Studios request, I started my latest project using Entity Framework Core (1.0.1) So writing my database models as I always have using the 'virtual' specifier to enable lazy loadin...

27 Dec at 08:52

What is the attribute in Xunit that's similar to TestContext in Visual studio tests?

We are migrating from visual studio tests to xunit.. In VStests we can access run time test parameters using TestContext. I am looking to set a global variable in the tests supplied at run time from c...

19 Oct at 02:23

Custom Model Binding in Asp .Net Core

i'm trying to bind a model with a *IFormFile* or *IFormFileCollection* property to my custom class *CommonFile*. i have not found so much documentation on internet about it using asp .net core, i trie...

19 Jul at 12:18

Set password on Zip file using DotNetZip

I'm using [DotNetZip](https://www.nuget.org/packages/DotNetZip/) to zip my files, but I need to set a password in zip. I tryed: ``` public void Zip(string path, string outputPath) { usin...

18 Oct at 18:41

Can I block on async code in MVC Core?

We all know [the famous blog post](http://blog.stephencleary.com/2012/07/dont-block-on-async-code.html) regarding blocking on async code by Stephen Cleary. In MVC 5 the following code deadlocks when r...

18 Oct at 17:24

How do I fix garbled Chinese?

I have a swagger API. How do I resolve the garbled Chinese characters ([GB2312](https://en.wikipedia.org/wiki/GB_2312))? ``` server.ServiceModel.Customer { Email: "test01@*foxmail*.com" Logi...

20 Oct at 00:17