Short solution for short problems

IIS copy files to file share in API or web site

Recently, I needed to copy some files from a database to a file share in a .Net web API that runs on an IIS. First I was trying to run the application pool using a domain user, but I couldn't get it working. The application pool keeps stopping, even if the username and password is correct and the local policies are correct.

So I found another better way to do it. In stead of giving the user permissions on the file share. I gave the server permissions on the file share. Then I ran the application pool under the NetworkService and it works.

On the file share under security, put DOMAIN\SERVERNAME and give modify rights (do not forget to include computers in de AD search). Thats it. Now the server can write to this specific location, no harm can be done. In fact, giving a user permissions can be more dangerous, because he can access it anywhere.

AngularJS and .Net WEB.API: 405 (Method Not Allowed) for PUT and DELETE

I was having some problems with put and deletes. When I ran the code on the localhost, no problem, but after installing on the servers, delete calls were giving CORS errors. I tried to figure out what was going on, but I lost some time. First I rewrote the methods to POST methods, this worked. But when a new occasion came to look for a better solution I found it here.

The thing is that DELETE and PUT are sending a OPTION request first to the API on the server. If this method is not there, then it will not work. The error message will not really point you into the right direction. 

But instead of adding the OPTION methods foreach DELETE or PUT you could also disable WebDAV in IIS. That really does the trick. No code changes needed, just a simple configuration.

  <modules runAllManagedModulesForAllRequests="true">
    <remove name="WebDAVModule"/>
    <remove name="WebDAV" />

And thatis it.

No more of these now:

Message count in MSQUEUE

An easy powershell comment can help to get more info about a messagequeue.

This get more info on all the queue's you have defined:

# Get all message queues

The next command gives youa table overview of all queue's and their item count:

# Get all the private message queues.
# Display only the QueueName and MessageCount for each queue.
Get-MsmqQueue -QueueType Private | Format-Table -Property QueueName,MessageCount;

Source Link

You could off also take a look in the queue browser:

EF: Oracle.ManagedDataAccess Specified Cast is not valid on decimal

Error: Specified cast is not valid. 

CorrId: GetClientAcceptances 

Stack: at Oracle.ManagedDataAccess.Client.OracleDataReader.GetDecimal(Int32 i) 

at Oracle.ManagedDataAccess.Client.OracleDataReader.GetValue(Int32 i)

Got this error while working with EF 6 and Oracle DB. Using the Oracle.ManagedDataAccess package. (Version about packages below)

The reason was that in Oracle the number type was set on a column and no precision specified. We had some old data that had some values with a very large precision, and when EF tries to map it to a decimal, there was a specified cast exception. So I rounded all the records in the DB to precision 2, because that was enough for this application and the problem was solved. Some helper query for this:

select RISKFACTOR from MYTABLE where RISKFACTOR - trunc(RISKFACTOR,3) <> 0;

  <package id="Oracle.ManagedDataAccess" version="12.1.24160719" targetFramework="net461" />

  <package id="Oracle.ManagedDataAccess.EntityFramework" version="12.1.2400" targetFramework="net461" />

Passing objects in methods by ref or not....

public void Foo(Image image)
    // This change won't be seen by the caller: it's changing the value
    // of the parameter.
    image = Image.FromStream(...);

public void Foo(ref Image image)
    // This change *will* be seen by the caller: it's changing the value
    // of the parameter, but we're using pass by reference
    image = Image.FromStream(...);

public void Foo(Image image)
    // This change *will* be seen by the caller: it's changing the data
    // within the object that the parameter value refers to.
Source: Stackoverflow

AngularJS: How to build your own translation service PART 2

Ruben continued on the translation service blog resulting in a language picker that translates your entire site. You can find the post here:

How to – Build your own Angular translation service – Part 2 

Looking forward to PART 3 where Ruben B from Spikes will show how to implement json files to handle the translations, this way you can get the text from "any" data source.

AngularJS: How to build your own translation service

Ruben Biesemans started a post on how to implement your own translation service. Why you might ask. For him mainly educational purpose, for us, it's an opportunity to have a guideline on how to build your own translation service. Because many might find the existing solutions to complex or just not flexible enough. Here's a link to the part 1 and looking forward to the next part.

How to – Build your own Angular translation service – Part 1


Intro This will be a first in a series of posts in which I will build a translation service for Angular from the ground up. I want to point out up front that I know there are multiple angular trans… read more here

EF : Oracle and EF Code First “Invalid column name 'Discriminator'”

I got this little nasty error when working with EF6 and Oracle DB: ORA-00904: "Extent1"."Discriminator"

Didn't look that far, based on this post I found my answer!

I had a class: Clients, added to the context. 

That worked fine. 

Now I created a second class, ClientExtra not added to the context but this inherited from the Client object.

(Why you might ask, I used this class in a database query, it had some extra properties and no table reflecting in the already exiting DB)

After doing this, EF gave me the above error.

It could look like this:

public class Client
    public int Id { get; set; }

    public string Name { get; set; }

public class ClientExtra : Client
    public string City { get; set; }


First create a common base class, ClientBase, add all properties from the client object. Do not add the ClientBase to the context. Then you have Client en ClientExtra inherit from this base class without problems.

public class BaseClient
    public int Id { get; set; }

    public string Name { get; set; }

//In the context
public class Client : BaseClient
{ }

//Not in the context
public class ClientExtra : BaseClient
    public string City { get; set; }