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?

0

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

4 Comments

I have only using System.Security.Cryptography;. Csp and RSA are not availiable... maybe I'm missing some dependency
Did an update of my answer .. does it solve it for you?
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
Just found out that myself .. updated my answer accordingly

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.