Skip to content

Getting System.NullReferenceException #8

@jhakasjk

Description

@jhakasjk

I'm getting below exception while trying to decrypt the string.
"System.NullReferenceException: Object reference not set to an instance of an object.\r\n at CoreEntities.Classes.Utility.RSADecrypt(String input)\r\n at WebAPI.Attributes.ApiAuthorizeAttribute.Authorize(HttpActionContext actionContext)"

Code:-

public static string RSADecrypt(string input)
        {
            try
            {
                string priv = File.ReadAllText(HostingEnvironment.MapPath("~/Certificates/consumer.pem"));
                RSACryptoServiceProvider privc = Crypto.DecodeRsaPrivateKey(priv);
                return Crypto.DecryptString(input, privc);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

It is only coming when i deploy my application on windows server 2012 although it's working fine on local machine on iis and via visual studio 2015.

How to fix this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions