我正在使用官方文档中IOptions描述的模式.
当我从中读取值时appsetting.json,这可以正常工作,但是如何更新值并将更改保存回来appsetting.json?
在我的例子中,我有几个字段可以从用户界面编辑(由管理员用户在应用程序中).因此,我正在寻找通过选项访问器更新这些值的理想方法.
我按照文章将 WCF 服务包含到我的 ASP.NET 核心应用程序中。
查看reference.cs 中的以下行,似乎默认端点配置是在reference.cs 中硬编码的。
return new System.ServiceModel.EndpointAddress("http://localhost:49945/SimpleService.svc");
Run Code Online (Sandbox Code Playgroud)
这就是我如何在 asp.net 核心控制器中创建我的客户端 -
BasicHttpBinding basicHttpBinding = new BasicHttpBinding();
EndpointAddress endpointAddress = new EndpointAddress("http://localhost:49945/SimpleService.svc");
wcfClient = new SimpleServiceClient(basicHttpBinding, endpointAddress);
Run Code Online (Sandbox Code Playgroud)
所以我的问题是——
我应该在哪里维护端点详细信息,以便在部署期间可以轻松配置?
如何从配置文件 (appsetting.json)动态传递端点详细信息(地址和绑定)?
生成的 Reference.cs 文件如下所示 -
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// //
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace SimpleServiceReference …Run Code Online (Sandbox Code Playgroud)