Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

add dynamic value in startup file in .net core api

public void ConfigureServices(IServiceCollection services)
{
     Action<MDUOptions> mduOptions = (opt =>
     {
          opt.CompanyCode = "aaaa";
     });
     services.Configure(mduOptions);
     services.AddSingleton(resolver => resolver.GetRequiredService<IOptions<MDUOptions>>().Value);
     services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
}
Source by forums.asp.net #
 
PREVIOUS NEXT
Tagged: #add #dynamic #startup #file #core #api
ADD COMMENT
Topic
Name
6+2 =