{"id":18739969,"url":"https://github.com/springleee/viewconfig","last_synced_at":"2025-04-12T20:04:35.040Z","repository":{"id":115818741,"uuid":"352556014","full_name":"SpringLeee/ViewConfig","owner":"SpringLeee","description":null,"archived":false,"fork":false,"pushed_at":"2021-07-06T05:19:18.000Z","size":21,"stargazers_count":14,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-12T20:04:28.626Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SpringLeee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-29T07:37:43.000Z","updated_at":"2022-04-18T07:45:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"ead121d8-6d96-440f-923c-6439f1819d41","html_url":"https://github.com/SpringLeee/ViewConfig","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpringLeee%2FViewConfig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpringLeee%2FViewConfig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpringLeee%2FViewConfig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpringLeee%2FViewConfig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SpringLeee","download_url":"https://codeload.github.com/SpringLeee/ViewConfig/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248625493,"owners_count":21135513,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T15:38:04.158Z","updated_at":"2025-04-12T20:04:35.033Z","avatar_url":"https://github.com/SpringLeee.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"## ViewConfig 介绍\n\n在本文中，我们在.NET Core 程序中使用了 `ViewConfig` 组件来调试配置。\n\n\n## 安装\n\n通过Nuget搜索 `ViewConfig`，然后在程序中安装，这是一个.net standard 2.0 的组件。 \n\n![](https://blog-1259586045.cos.ap-shanghai.myqcloud.com/clipboard_20210330_054359.png)\n\n## 设置\n\n安装完成以后，需要修改 Startup.cs 文件的 Configure 方法，我们加一行代码 `UseViewConfig`\n\n```csharp\npublic void Configure(IApplicationBuilder app, IWebHostEnvironment env)\n{ \n\tif (env.IsDevelopment())\n\t{\n\t\tapp.UseViewConfig();\n\n\t\tapp.UseDeveloperExceptionPage();\n\t\tapp.UseSwagger(); \n\n\t\t// ...\n\n} \n```\n\n这里建议在开发环境中使用，和Swagger一样， 然后我们启动程序，然后访问 `/viewconfig` 端点 \n\n![](https://blog-1259586045.cos.ap-shanghai.myqcloud.com/clipboard_20210330_062154.png)\n\n上面列出了程序中所有的配置项，我们可以看到 Key，Value，也可以通过 Provider 知道配置来自与 appsetting.json 文件或者其他，可以通过下拉列表查看不同的 Provider 的配置信息。\n\n## 自定义\n\n默认使用的是 `/viewconfig` 端点，输出的是页面，当然也支持输出 json 和文本，像下面这样\n\n```csharp\n// 自定义端点\napp.UseViewConfig(x =\u003e x.Map(\"/Info\")); \n\n// 页面格式\napp.UseViewConfig(x =\u003e x.RenderPage()); \n\n// Json格式\napp.UseViewConfig(x =\u003e x.Map().RenderJson()); \n\n// 文本格式\napp.UseViewConfig(x =\u003e x.Map(\"/Info\").RenderText());   \n```\n\n## 总结\n\nViewConfig 是一个非常简单的组件，可以帮助我们在.NET Core 程序中调试配置信息，接下来还会支持在.Net Core 控制台项目中使用，需要注意的是，我建议大家只在开发环境中使用它，希望可以对您有帮助。\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspringleee%2Fviewconfig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspringleee%2Fviewconfig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspringleee%2Fviewconfig/lists"}