appsettings

How can I retrieve AppSettings configuration back in Asp.Net MVC 6?

泄露秘密 提交于 2019-12-01 01:34:18
问题 Assuming that I am using the new DepencyInjection framework to configure my classes and dependencies in the new ASP.Net/vNext. How can I use, How can I get my pre-defined configuration settings? public void ConfigureServices(IServiceCollection services) { // Add Application settings to the services container. services.Configure<AppSettings>(Configuration.GetSubKey("AppSettings")); // Add EF services to the services container. services.AddEntityFramework() .AddSqlServer() .AddDbContext

In App settings tableview from Settings bundle

微笑、不失礼 提交于 2019-11-30 16:45:38
I want to create a TableView which is automatically generated from the Settings.bundle . There used to be a framework InAppSettings but this isn't working with iOS 7 and up . Is there any other code/tutorial for this? I have been searching around and couldn't find a boilerplate solution so created my own code for doing this. It supports the setting types Title , Group , Text Field , Multi Value and Toggle Switch . It does NOT SUPPORT Slider . This solution does support portrait AND landscape mode and can also handle changing over device orientations. I have published the code and readme on my

In App settings tableview from Settings bundle

試著忘記壹切 提交于 2019-11-30 16:20:31
问题 I want to create a TableView which is automatically generated from the Settings.bundle . There used to be a framework InAppSettings but this isn't working with iOS 7 and up . Is there any other code/tutorial for this? 回答1: I have been searching around and couldn't find a boilerplate solution so created my own code for doing this. It supports the setting types Title , Group , Text Field , Multi Value and Toggle Switch . It does NOT SUPPORT Slider . This solution does support portrait AND

ConfigurationSettings.AppSettings is obsolete, warning

牧云@^-^@ 提交于 2019-11-30 15:16:41
var values = new NameValueCollection { { "key", ConfigurationSettings.AppSettings["API-Key"].ToString() }, { "image", Convert.ToBase64String(File.ReadAllBytes(photo.ToString())) } }; What's the new way to use the app.config file? Kelsey The ConfigurationManager class in System.Configuration : ConfigurationManager.AppSettings ConfigurationManager.ConnectionStrings So your code would change to: var values = new NameValueCollection { { "key", ConfigurationManager.AppSettings["API-Key"] }, { "image", Convert.ToBase64String(File.ReadAllBytes(photo.ToString())) } }; Make sure you add a reference to

Read appsettings.json from a class in .NET Core 2

别等时光非礼了梦想. 提交于 2019-11-30 11:39:13
I need to read a list of properties from appsettings.json file (section: placeto ) in a business class, but I haven't been able to access them. I need these properties to be public. I add the file in the Program class: This is my appsettings.json : { "Logging": { "IncludeScopes": false, "LogLevel": { "Default": "Warning" } }, "placeto": { "login": "fsdfsdfsfddfdfdfdf", "trankey": "sdfsdfsdfsdfsdf" } } Mohamad Elnaqeeb First : Use the default in program.cs for it already adds Configuration: public class Program { public static void Main(string[] args) { BuildWebHost(args).Run(); } public static

Read appsettings json values in .NET Core Test Project

a 夏天 提交于 2019-11-30 10:49:26
My Web application needs to read the Document DB keys from appsettings.json file. I have created a class with the key names and reading the Config section in ConfigureaServices() as: public Startup(IHostingEnvironment env) { var builder = new ConfigurationBuilder() .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .AddEnvironmentVariables(); Configuration = builder.Build(); } public IConfigurationRoot Configuration { get; } public void ConfigureServices(IServiceCollection services) { services.AddMvc().AddJsonOptions(options => options.SerializerSettings.ContractResolver =

Access appsettings.json values in controller classes

纵然是瞬间 提交于 2019-11-30 08:53:52
Having trouble figuring out how to read appsettings.json values outside of the startup.cs. What I would like to do is, for instance, is in the _Layout.cshtml, add the site name from the config: For example: ViewData["SiteName"] = Configuration.GetValue<string>("SiteSettings:SiteName"); Or even better: public class GlobalVars { public static string SiteName => Configuration.GetValue<string>("SiteSettings:SiteName"); } Here's my code thus far: [appsettings.json] "SiteSettings": { "SiteName": "MySiteName" } [startup.cs] public Startup(IHostingEnvironment env) { var builder = new

Inject App Settings using Windsor

此生再无相见时 提交于 2019-11-30 08:38:32
How can I inject the value of an appSettings entry (from app.config or web.config) into a service using the Windsor container? If I wanted to inject the value of a Windsor property into a service, I would do something like this: <properties> <importantIntegerProperty>666</importantIntegerProperty> </properties> <component id="myComponent" service="MyApp.IService, MyApp" type="MyApp.Service, MyApp" > <parameters> <importantInteger>#{importantIntegerProperty}</importantInteger> </parameters> </component> However, what I'd really like to do is take the value represented by #

Form submit resulting in “InvalidDataException: Form value count limit 1024 exceeded.”

≡放荡痞女 提交于 2019-11-30 07:59:43
I have created an mvc site and I'm posting a large amount of json form data ( Content-Type:application/x-www-form-urlencoded ) back to the mvc controller. When I do this, I receive a 500 response that states: "InvalidDataException: Form value count limit 1024 exceeded." In previous versions of aspnet, you would add the following to the web.config to increase the limit: <appSettings> <add key="aspnet:MaxHttpCollectionKeys" value="5000" /> <add key="aspnet:MaxJsonDeserializerMembers" value="5000" /> </appSettings> When I put these values in the web.config, I do not see any change, so I'm

Can I set listen URLs in appsettings.json in ASP.net Core 2.0 Preview?

风格不统一 提交于 2019-11-30 06:59:38
I'm creating an ASP.net Core 2.0 app to run on the .net Core 2.0 runtime, both currently in their Preview versions. However, I cannot figure out how to have Kestrel use something other than the default http://localhost:5000 listen URL. Most documentation that I could Google talks about a server.urls setting, which seems to have been changed even in 1.0-preview to just be urls , however neither works (turning on Debug logging has Kestrel telling me that no listen endpoints are configured). A lot of documentation also talks about a hosting.json and that I can't use the default appsettings.json.