Your Okta URL is missing. ASP.NET 4.5.x

Hi!
I’m running through an exception error while trying to setup OIDC on my project.
I have setup the my URL, but when I run the project, the exception error says that the the attribute has a null value.

I have searched in the forum for a similar question but wasn’t able to find any answer. Any help would be great.


Hey @j2iro, the error is occurring because your syntax for ConfigurationManager.AppSettings is not quite right.

If you use ConfigurationManager.AppSettings, the value should be stored in Web.config, and you look it up by the key. This blog post covers the syntax: http://www.nikola-breznjak.com/blog/windows/c/how-to-use-app-config-in-visual-studio-c-net/

In other words, you can either do:

new OktaMvcOptions()
{
  OktaDomain = "https://example.com"
}

Or you can do:

new OktaMvcOptions()
{
  OktaDomain = ConfigurationManager.AppSettings["domain"]
}

and put this in Web.config:

<add key="domain" value="https://example.com" />

Our ASP.NET sample app shows an example:


1 Like

@nate.barbettini Thank you so much. This solved my problem
The problem was that my ConfigurationManager.AppSettings values did not map with the keys as you correctly advised.

In my Web.config I had key="okta:OktaDomain" with the respective value but did not map ConfigurationManager.AppSettings["okta:OktaDomain"]

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.