1

I'm trying to create WebApi with token-based authentication in my ASP.NET 5 app. I'm following these steps https://stackoverflow.com/a/29698502/2420851 . But I'm stuck already at the first one with creating RSA key.

Line RSACryptoServiceProvider myRSA = new RSACryptoServiceProvider(2048);

produces compilation error The type 'RSACryptoServiceProvider' exists in both 'System.Security.Cryptography.Csp' and 'System.Security.Cryptography.RSA'

when I add "System.Security.Cryptography.RSA": "4.0.0-beta-22819" to my project.json error message just changes to The type 'RSACryptoServiceProvider' exists in both 'System.Security.Cryptography.RSA' and 'mscorlib'

Namespaces System.Security.Cryptography.RSA and System.Security.Cryptography.Csp are both unavailable.

How can I resolve this?

Community
  • 1
  • 1
vebbo
  • 240
  • 5
  • 14

1 Answers1

1

Updated

Do like this:

System.Security.Cryptography.RSACryptoServiceProvider myRSA = new System.Security.Cryptography.RSACryptoServiceProvider(2048);

or you have to remove the colliding imported namespaces and only have the "using System.Security.Cryptography"

If you are using ASP.NET 5 Core then you need to check this question on how to get Crypt to work:

Which encryption algorithm do we use in Asp.net 5 Core

or remove "dnxcore50" from your project.

Community
  • 1
  • 1
Asons
  • 84,923
  • 12
  • 110
  • 165
  • I have only ``using System.Security.Cryptography;``. ``Csp`` and ``RSA`` are not availiable... maybe I'm missing some dependency – vebbo Sep 12 '15 at 12:07
  • Did an update of my answer .. does it solve it for you? – Asons Sep 12 '15 at 13:33
  • 1
    No, i tried this before. However I solved the problem. It was about .NET Core, I removed dnxcore50 from project.json and it worked. Thanks anyway – vebbo Sep 12 '15 at 13:41
  • Just found out that myself .. updated my answer accordingly – Asons Sep 12 '15 at 13:44