{"id":41735,"date":"2025-06-04T03:23:51","date_gmt":"2025-06-03T19:23:51","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/41735.html"},"modified":"2025-06-04T03:23:51","modified_gmt":"2025-06-03T19:23:51","slug":"net-consul%e6%9c%8d%e5%8a%a1%e6%b3%a8%e5%86%8c%e4%b8%8e%e5%8f%91%e7%8e%b0","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/41735.html","title":{"rendered":".net consul\u670d\u52a1\u6ce8\u518c\u4e0e\u53d1\u73b0"},"content":{"rendered":"<h2>.NET\u4e2dConsul\u670d\u52a1\u6ce8\u518c\u4e0e\u53d1\u73b0\u7684\u6280\u672f\u5b9e\u8df5<\/h2>\n<p>\u5728\u5fae\u670d\u52a1\u67b6\u6784\u4e2d&#xff0c;\u670d\u52a1\u7684\u6ce8\u518c\u4e0e\u53d1\u73b0\u662f\u81f3\u5173\u91cd\u8981\u7684\u73af\u8282&#xff0c;\u5b83\u80fd\u5e2e\u52a9\u5404\u4e2a\u670d\u52a1\u4e4b\u95f4\u5b9e\u73b0\u9ad8\u6548\u7684\u901a\u4fe1\u548c\u534f\u4f5c\u3002Consul\u4f5c\u4e3a\u4e00\u6b3e\u529f\u80fd\u5f3a\u5927\u7684\u5de5\u5177&#xff0c;\u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86\u4f18\u79c0\u7684\u670d\u52a1\u6ce8\u518c\u4e0e\u53d1\u73b0\u89e3\u51b3\u65b9\u6848\u3002\u4eca\u5929&#xff0c;\u6211\u4eec\u5c31\u6765\u8be6\u7ec6\u63a2\u8ba8\u4e00\u4e0b\u5728.NET\u73af\u5883\u4e2d\u5982\u4f55\u4f7f\u7528Consul\u8fdb\u884c\u670d\u52a1\u6ce8\u518c\u4e0e\u53d1\u73b0\u3002<\/p>\n<h3>\u4e00\u3001Consul\u6838\u5fc3\u529f\u80fd\u5256\u6790<\/h3>\n<p>Consul\u5177\u5907\u591a\u9879\u6838\u5fc3\u529f\u80fd&#xff0c;\u8fd9\u4e9b\u529f\u80fd\u4e3a\u5206\u5e03\u5f0f\u7cfb\u7edf\u7684\u6784\u5efa\u63d0\u4f9b\u4e86\u5f3a\u5927\u652f\u6301&#xff1a;<\/p>\n<li>\u670d\u52a1\u53d1\u73b0&#xff1a;\u901a\u8fc7DNS\u6216HTTP\u63a5\u53e3&#xff0c;\u670d\u52a1\u53ef\u4ee5\u8f7b\u677e\u6ce8\u518c\u81ea\u5df1&#xff0c;\u5e76\u8ba9\u5ba2\u6237\u7aef\u80fd\u591f\u65b9\u4fbf\u5730\u627e\u5230\u5e76\u8c03\u7528\u6240\u9700\u670d\u52a1\u3002\u8fd9\u6781\u5927\u5730\u7b80\u5316\u4e86\u670d\u52a1\u4e4b\u95f4\u7684\u8c03\u7528\u6d41\u7a0b&#xff0c;\u63d0\u9ad8\u4e86\u7cfb\u7edf\u7684\u7075\u6d3b\u6027\u548c\u53ef\u7ef4\u62a4\u6027\u3002<\/li>\n<li>\u5065\u5eb7\u68c0\u67e5&#xff1a;\u5b9a\u671f\u5bf9\u96c6\u7fa4\u4e2d\u7684\u670d\u52a1\u72b6\u6001\u8fdb\u884c\u76d1\u63a7&#xff0c;\u4e00\u65e6\u53d1\u73b0\u670d\u52a1\u51fa\u73b0\u6545\u969c&#xff0c;\u80fd\u591f\u53ca\u65f6\u53d1\u51fa\u544a\u8b66\u3002\u8fd9\u6709\u52a9\u4e8e\u4fdd\u8bc1\u670d\u52a1\u7684\u53ef\u7528\u6027&#xff0c;\u51cf\u5c11\u7cfb\u7edf\u6545\u969c\u5e26\u6765\u7684\u5f71\u54cd\u3002<\/li>\n<li>\u952e\u503c\u5b58\u50a8&#xff1a;\u63d0\u4f9b\u4e86\u4e00\u4e2a\u7b80\u5355\u7684HTTP\u63a5\u53e3&#xff0c;\u7528\u4e8e\u5b58\u50a8\u52a8\u6001\u914d\u7f6e\u4fe1\u606f\u3002\u5f00\u53d1\u4eba\u5458\u53ef\u4ee5\u5728\u4efb\u4f55\u5730\u65b9\u901a\u8fc7\u8fd9\u4e2a\u63a5\u53e3\u5bf9\u914d\u7f6e\u4fe1\u606f\u8fdb\u884c\u64cd\u4f5c&#xff0c;\u65b9\u4fbf\u5bf9\u7cfb\u7edf\u8fdb\u884c\u52a8\u6001\u914d\u7f6e\u548c\u7ba1\u7406\u3002<\/li>\n<li>\u591a\u6570\u636e\u4e2d\u5fc3\u652f\u6301&#xff1a;\u65e0\u9700\u590d\u6742\u7684\u914d\u7f6e&#xff0c;\u5373\u53ef\u652f\u6301\u4efb\u610f\u6570\u91cf\u7684\u533a\u57df&#xff0c;\u6ee1\u8db3\u4e86\u5206\u5e03\u5f0f\u7cfb\u7edf\u5728\u4e0d\u540c\u5730\u7406\u4f4d\u7f6e\u90e8\u7f72\u7684\u9700\u6c42\u3002<\/li>\n<h3>\u4e8c\u3001\u5728.NET Core\u4e2d\u4f7f\u7528Consul\u7684\u5177\u4f53\u6b65\u9aa4<\/h3>\n<h4>1. \u670d\u52a1\u6ce8\u518c<\/h4>\n<p>\u5728\u4f7f\u7528Consul\u8fdb\u884c\u670d\u52a1\u6ce8\u518c\u4e4b\u524d&#xff0c;\u9700\u8981\u786e\u4fddConsul\u670d\u52a1\u5df2\u7ecf\u542f\u52a8\u5e76\u4e14\u53ef\u4ee5\u5728\u7f51\u7edc\u4e0a\u6b63\u5e38\u8bbf\u95ee\u3002\u4ee5\u4e0b\u662f\u5728.NET Core\u5e94\u7528\u7a0b\u5e8f\u4e2d\u6ce8\u518c\u670d\u52a1\u5230Consul\u7684\u8be6\u7ec6\u6b65\u9aa4\u548c\u793a\u4f8b\u4ee3\u7801&#xff1a; \u9996\u5148&#xff0c;\u6dfb\u52a0Consul\u7684NuGet\u5305\u5230\u9879\u76ee\u4e2d\u3002\u7136\u540e&#xff0c;\u521b\u5efaConsul\u5ba2\u6237\u7aef\u914d\u7f6e&#xff1a;<\/p>\n<p><span class=\"token comment\">\/\/ \u521b\u5efaConsul\u5ba2\u6237\u7aef\u914d\u7f6e<\/span><br \/>\n<span class=\"token class-name\"><span class=\"token keyword\">var<\/span><\/span> consulConfig <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">new<\/span> <span class=\"token constructor-invocation class-name\">ConsulConfiguration<\/span><span class=\"token punctuation\">(<\/span>c <span class=\"token operator\">&#061;&gt;<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    c<span class=\"token punctuation\">.<\/span>Address <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">new<\/span> <span class=\"token constructor-invocation class-name\">Uri<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;http:\/\/localhost:8500&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ Consul\u670d\u52a1\u5730\u5740<\/span><br \/>\n    c<span class=\"token punctuation\">.<\/span>Datacenter <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;dc1&#034;<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u6570\u636e\u4e2d\u5fc3\u540d\u79f0<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u521b\u5efaConsul\u5ba2\u6237\u7aef<\/span><br \/>\n<span class=\"token keyword\">using<\/span> <span class=\"token class-name\"><span class=\"token keyword\">var<\/span><\/span> consulClient <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">new<\/span> <span class=\"token constructor-invocation class-name\">ConsulClient<\/span><span class=\"token punctuation\">(<\/span>consulConfig<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u670d\u52a1\u6ce8\u518c\u4fe1\u606f<\/span><br \/>\n<span class=\"token class-name\"><span class=\"token keyword\">var<\/span><\/span> registration <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">new<\/span> <span class=\"token constructor-invocation class-name\">AgentServiceRegistration<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    ID <span class=\"token operator\">&#061;<\/span> Guid<span class=\"token punctuation\">.<\/span><span class=\"token function\">NewGuid<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">ToString<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token comment\">\/\/ \u670d\u52a1\u552f\u4e00ID<\/span><br \/>\n    Name <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;my-dotnet-service&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token comment\">\/\/ \u670d\u52a1\u540d\u79f0<\/span><br \/>\n    Address <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;127.0.0.1&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token comment\">\/\/ \u670d\u52a1\u5730\u5740<\/span><br \/>\n    Port <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">5000<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token comment\">\/\/ \u670d\u52a1\u7aef\u53e3<\/span><br \/>\n    Tags <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">new<\/span><span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token string\">&#034;mytag&#034;<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token comment\">\/\/ \u670d\u52a1\u6807\u7b7e<\/span><br \/>\n    Check <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">new<\/span> <span class=\"token constructor-invocation class-name\">AgentServiceCheck<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token punctuation\">{<\/span><br \/>\n        DeregisterCriticalServiceAfter <span class=\"token operator\">&#061;<\/span> TimeSpan<span class=\"token punctuation\">.<\/span><span class=\"token function\">FromMinutes<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n        Interval <span class=\"token operator\">&#061;<\/span> TimeSpan<span class=\"token punctuation\">.<\/span><span class=\"token function\">FromSeconds<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">10<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n        HTTP <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;http:\/\/127.0.0.1:5000\/health&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token comment\">\/\/ \u5065\u5eb7\u68c0\u67e5\u5730\u5740<\/span><br \/>\n        Timeout <span class=\"token operator\">&#061;<\/span> TimeSpan<span class=\"token punctuation\">.<\/span><span class=\"token function\">FromSeconds<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">5<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u6ce8\u518c\u670d\u52a1\u5230Consul<\/span><br \/>\n<span class=\"token class-name\"><span class=\"token keyword\">var<\/span><\/span> result <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">await<\/span> consulClient<span class=\"token punctuation\">.<\/span>Agent<span class=\"token punctuation\">.<\/span><span class=\"token function\">ServiceRegister<\/span><span class=\"token punctuation\">(<\/span>registration<span class=\"token punctuation\">,<\/span> <span class=\"token named-parameter punctuation\">cancellationToken<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token keyword\">default<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>result<span class=\"token punctuation\">.<\/span>StatusCode <span class=\"token operator\">&#061;&#061;<\/span> System<span class=\"token punctuation\">.<\/span>Net<span class=\"token punctuation\">.<\/span>HttpStatusCode<span class=\"token punctuation\">.<\/span>OK<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    Console<span class=\"token punctuation\">.<\/span><span class=\"token function\">WriteLine<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Service registered successfully.&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token keyword\">else<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    Console<span class=\"token punctuation\">.<\/span><span class=\"token function\">WriteLine<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Failed to register service.&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d&#xff0c;\u6211\u4eec\u9996\u5148\u521b\u5efa\u4e86Consul\u5ba2\u6237\u7aef\u7684\u914d\u7f6e&#xff0c;\u6307\u5b9a\u4e86Consul\u670d\u52a1\u7684\u5730\u5740\u548c\u6570\u636e\u4e2d\u5fc3\u540d\u79f0\u3002\u7136\u540e\u521b\u5efa\u4e86\u670d\u52a1\u6ce8\u518c\u4fe1\u606f&#xff0c;\u5305\u62ec\u670d\u52a1\u7684\u552f\u4e00ID\u3001\u540d\u79f0\u3001\u5730\u5740\u3001\u7aef\u53e3\u3001\u6807\u7b7e\u4ee5\u53ca\u5065\u5eb7\u68c0\u67e5\u4fe1\u606f\u3002\u6700\u540e&#xff0c;\u4f7f\u7528Consul\u5ba2\u6237\u7aef\u5c06\u670d\u52a1\u6ce8\u518c\u5230Consul\u4e2d&#xff0c;\u5e76\u6839\u636e\u8fd4\u56de\u7ed3\u679c\u5224\u65ad\u6ce8\u518c\u662f\u5426\u6210\u529f\u3002<\/p>\n<h4>2. \u670d\u52a1\u53d1\u73b0<\/h4>\n<p>\u5b8c\u6210\u670d\u52a1\u6ce8\u518c\u540e&#xff0c;\u6211\u4eec\u8fd8\u9700\u8981\u80fd\u591f\u53d1\u73b0\u5176\u4ed6\u670d\u52a1\u3002\u4ee5\u4e0b\u662f\u5728.NET Core\u5e94\u7528\u7a0b\u5e8f\u4e2d\u67e5\u8be2Consul\u4ee5\u53d1\u73b0\u670d\u52a1\u7684\u793a\u4f8b\u4ee3\u7801&#xff1a;<\/p>\n<p><span class=\"token comment\">\/\/ \u521b\u5efaConsul\u5ba2\u6237\u7aef\u914d\u7f6e<\/span><br \/>\n<span class=\"token class-name\"><span class=\"token keyword\">var<\/span><\/span> consulConfig <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">new<\/span> <span class=\"token constructor-invocation class-name\">ConsulConfiguration<\/span><span class=\"token punctuation\">(<\/span>c <span class=\"token operator\">&#061;&gt;<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    c<span class=\"token punctuation\">.<\/span>Address <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">new<\/span> <span class=\"token constructor-invocation class-name\">Uri<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;http:\/\/localhost:8500&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ Consul\u670d\u52a1\u5730\u5740<\/span><br \/>\n    c<span class=\"token punctuation\">.<\/span>Datacenter <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;dc1&#034;<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u6570\u636e\u4e2d\u5fc3\u540d\u79f0<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u521b\u5efaConsul\u5ba2\u6237\u7aef<\/span><br \/>\n<span class=\"token keyword\">using<\/span> <span class=\"token class-name\"><span class=\"token keyword\">var<\/span><\/span> consulClient <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">new<\/span> <span class=\"token constructor-invocation class-name\">ConsulClient<\/span><span class=\"token punctuation\">(<\/span>consulConfig<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u67e5\u8be2\u670d\u52a1<\/span><br \/>\n<span class=\"token class-name\"><span class=\"token keyword\">var<\/span><\/span> queryResult <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">await<\/span> consulClient<span class=\"token punctuation\">.<\/span>Catalog<span class=\"token punctuation\">.<\/span><span class=\"token function\">Service<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;my-dotnet-service&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>queryResult<span class=\"token punctuation\">.<\/span>StatusCode <span class=\"token operator\">&#061;&#061;<\/span> System<span class=\"token punctuation\">.<\/span>Net<span class=\"token punctuation\">.<\/span>HttpStatusCode<span class=\"token punctuation\">.<\/span>OK<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">foreach<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token class-name\"><span class=\"token keyword\">var<\/span><\/span> service <span class=\"token keyword\">in<\/span> queryResult<span class=\"token punctuation\">.<\/span>Response<span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token class-name\"><span class=\"token keyword\">var<\/span><\/span> client <span class=\"token operator\">&#061;<\/span> _httpClientFactory<span class=\"token punctuation\">.<\/span><span class=\"token function\">CreateClient<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token class-name\"><span class=\"token keyword\">var<\/span><\/span> response <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">await<\/span> client<span class=\"token punctuation\">.<\/span><span class=\"token function\">GetAsync<\/span><span class=\"token punctuation\">(<\/span><span class=\"token interpolation-string\"><span class=\"token string\">$&#034;http:\/\/<\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span><span class=\"token expression language-csharp\">service<span class=\"token punctuation\">.<\/span>ServiceAddress<\/span><span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">:<\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span><span class=\"token expression language-csharp\">service<span class=\"token punctuation\">.<\/span>ServicePort<\/span><span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">\/test\/get&#034;<\/span><\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token class-name\"><span class=\"token keyword\">var<\/span><\/span> result <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">await<\/span> response<span class=\"token punctuation\">.<\/span>Content<span class=\"token punctuation\">.<\/span><span class=\"token function\">ReadAsStringAsync<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u5728\u8fd9\u6bb5\u4ee3\u7801\u4e2d&#xff0c;\u6211\u4eec\u540c\u6837\u5148\u521b\u5efa\u4e86Consul\u5ba2\u6237\u7aef\u7684\u914d\u7f6e\u548c\u5ba2\u6237\u7aef\u5b9e\u4f8b\u3002\u7136\u540e\u4f7f\u7528Catalog.Service\u65b9\u6cd5\u67e5\u8be2\u540d\u4e3amy-dotnet-service\u7684\u670d\u52a1&#xff0c;\u8be5\u65b9\u6cd5\u4f1a\u8fd4\u56de\u6ce8\u518c\u5230Consul\u7684\u6240\u6709\u8be5\u670d\u52a1\u7684\u5b9e\u4f8b\u4fe1\u606f\u3002\u5982\u679c\u67e5\u8be2\u6210\u529f&#xff0c;\u6211\u4eec\u53ef\u4ee5\u904d\u5386\u8fd9\u4e9b\u5b9e\u4f8b\u4fe1\u606f&#xff0c;\u5e76\u4f7f\u7528HttpClient\u8c03\u7528\u670d\u52a1\u7684\u63a5\u53e3\u3002<\/p>\n<h4>3. \u6ce8\u610f\u4e8b\u9879<\/h4>\n<p>\u5728\u8fdb\u884c\u670d\u52a1\u6ce8\u518c\u548c\u53d1\u73b0\u65f6&#xff0c;\u9700\u8981\u786e\u4fdd\u670d\u52a1\u7aef\u53e3\u662f\u6253\u5f00\u7684&#xff0c;\u5e76\u4e14\u670d\u52a1\u5df2\u7ecf\u542f\u52a8\u4e86\u5065\u5eb7\u68c0\u67e5\u7aef\u70b9\u3002Consul\u4f1a\u5b9a\u671f\u8c03\u7528\u8fd9\u4e2a\u7aef\u70b9\u6765\u68c0\u67e5\u670d\u52a1\u7684\u5065\u5eb7\u72b6\u51b5&#xff0c;\u53ea\u6709\u5065\u5eb7\u7684\u670d\u52a1\u624d\u4f1a\u88ab\u5ba2\u6237\u7aef\u53d1\u73b0\u548c\u8c03\u7528\u3002<\/p>\n<h3>\u4e09\u3001\u914d\u7f6e\u7ba1\u7406&#xff08;\u53ef\u9009&#xff09;<\/h3>\n<p>Consul\u8fd8\u63d0\u4f9b\u4e86\u952e\u503c\u5b58\u50a8\u529f\u80fd&#xff0c;\u53ef\u4ee5\u7528\u6765\u5b58\u50a8\u914d\u7f6e\u4fe1\u606f\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528Consul\u5ba2\u6237\u7aef\u5e93\u6765\u8bfb\u53d6\u548c\u66f4\u65b0\u8fd9\u4e9b\u914d\u7f6e&#xff0c;\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b&#xff1a;<\/p>\n<p><span class=\"token class-name\"><span class=\"token keyword\">var<\/span><\/span> consulConfig <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">new<\/span> <span class=\"token constructor-invocation class-name\">ConsulConfiguration<\/span><span class=\"token punctuation\">(<\/span>x <span class=\"token operator\">&#061;&gt;<\/span> x<span class=\"token punctuation\">.<\/span>Address <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">new<\/span> <span class=\"token constructor-invocation class-name\">Uri<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;http:\/\/localhost:8500&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">using<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token class-name\"><span class=\"token keyword\">var<\/span><\/span> consulClient <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">new<\/span> <span class=\"token constructor-invocation class-name\">ConsulClient<\/span><span class=\"token punctuation\">(<\/span>consulConfig<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u8bbe\u7f6e\u914d\u7f6e<\/span><br \/>\n    <span class=\"token class-name\"><span class=\"token keyword\">var<\/span><\/span> putResult <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">await<\/span> consulClient<span class=\"token punctuation\">.<\/span>KV<span class=\"token punctuation\">.<\/span><span class=\"token function\">Put<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">new<\/span> <span class=\"token constructor-invocation class-name\">KVPair<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;config\/mykey&#034;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> Value <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;myvalue&#034;<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ \u83b7\u53d6\u914d\u7f6e<\/span><br \/>\n    <span class=\"token class-name\"><span class=\"token keyword\">var<\/span><\/span> getResult <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">await<\/span> consulClient<span class=\"token punctuation\">.<\/span>KV<span class=\"token punctuation\">.<\/span><span class=\"token function\">Get<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;config\/mykey&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>getResult<span class=\"token punctuation\">.<\/span>Response <span class=\"token operator\">!&#061;<\/span> <span class=\"token keyword\">null<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token punctuation\">{<\/span><br \/>\n        Console<span class=\"token punctuation\">.<\/span><span class=\"token function\">WriteLine<\/span><span class=\"token punctuation\">(<\/span><span class=\"token interpolation-string\"><span class=\"token string\">$&#034;Value for &#039;config\/mykey&#039;: <\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span><span class=\"token expression language-csharp\">System<span class=\"token punctuation\">.<\/span>Text<span class=\"token punctuation\">.<\/span>Encoding<span class=\"token punctuation\">.<\/span>UTF8<span class=\"token punctuation\">.<\/span><span class=\"token function\">GetString<\/span><span class=\"token punctuation\">(<\/span>getResult<span class=\"token punctuation\">.<\/span>Response<span class=\"token punctuation\">.<\/span>Value<span class=\"token punctuation\">)<\/span><\/span><span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">&#034;<\/span><\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d&#xff0c;\u6211\u4eec\u4f7f\u7528KV.Put\u65b9\u6cd5\u8bbe\u7f6e\u914d\u7f6e\u4fe1\u606f&#xff0c;\u4f7f\u7528KV.Get\u65b9\u6cd5\u83b7\u53d6\u914d\u7f6e\u4fe1\u606f\u3002\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f&#xff0c;\u6211\u4eec\u53ef\u4ee5\u65b9\u4fbf\u5730\u5bf9\u7cfb\u7edf\u7684\u914d\u7f6e\u4fe1\u606f\u8fdb\u884c\u7ba1\u7406\u3002<\/p>\n<h3>\u56db\u3001\u603b\u7ed3<\/h3>\n<p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4&#xff0c;\u6211\u4eec\u53ef\u4ee5\u5728.NET Core\u5e94\u7528\u7a0b\u5e8f\u4e2d\u8f7b\u677e\u5b9e\u73b0\u57fa\u4e8eConsul\u7684\u670d\u52a1\u6ce8\u518c\u4e0e\u53d1\u73b0\u4ee5\u53ca\u914d\u7f6e\u7ba1\u7406\u3002Consul\u7684\u5f3a\u5927\u529f\u80fd\u4e3a\u5fae\u670d\u52a1\u67b6\u6784\u7684\u6784\u5efa\u63d0\u4f9b\u4e86\u6709\u529b\u652f\u6301&#xff0c;\u80fd\u591f\u5e2e\u52a9\u6211\u4eec\u6784\u5efa\u66f4\u52a0\u7a33\u5b9a\u3001\u9ad8\u6548\u7684\u5206\u5e03\u5f0f\u7cfb\u7edf\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d&#xff0c;\u6211\u4eec\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u9700\u6c42\u5bf9\u670d\u52a1\u6ce8\u518c\u548c\u53d1\u73b0\u7684\u903b\u8f91\u8fdb\u884c\u4f18\u5316\u548c\u6269\u5c55&#xff0c;\u4ee5\u6ee1\u8db3\u4e0d\u540c\u7684\u4e1a\u52a1\u573a\u666f\u3002\u5e0c\u671b\u672c\u6587\u80fd\u5bf9\u5927\u5bb6\u5728.NET\u4e2d\u4f7f\u7528Consul\u8fdb\u884c\u670d\u52a1\u6ce8\u518c\u4e0e\u53d1\u73b0\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb969\u6b21\uff0c\u70b9\u8d5e5\u6b21\uff0c\u6536\u85cf6\u6b21\u3002\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u6211\u4eec\u53ef\u4ee5\u5728.NET Core\u5e94\u7528\u7a0b\u5e8f\u4e2d\u8f7b\u677e\u5b9e\u73b0\u57fa\u4e8eConsul\u7684\u670d\u52a1\u6ce8\u518c\u4e0e\u53d1\u73b0\u4ee5\u53ca\u914d\u7f6e\u7ba1\u7406\u3002Consul\u7684\u5f3a\u5927\u529f\u80fd\u4e3a\u5fae\u670d\u52a1\u67b6\u6784\u7684\u6784\u5efa\u63d0\u4f9b\u4e86\u6709\u529b\u652f\u6301\uff0c\u80fd\u591f\u5e2e\u52a9\u6211\u4eec\u6784\u5efa\u66f4\u52a0\u7a33\u5b9a\u3001\u9ad8\u6548\u7684\u5206\u5e03\u5f0f\u7cfb\u7edf\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u9700\u6c42\u5bf9\u670d\u52a1\u6ce8\u518c\u548c\u53d1\u73b0\u7684\u903b\u8f91\u8fdb\u884c\u4f18\u5316\u548c\u6269\u5c55\uff0c\u4ee5\u6ee1\u8db3\u4e0d\u540c\u7684\u4e1a\u52a1\u573a\u666f\u3002\u5e0c\u671b\u672c\u6587\u80fd\u5bf9\u5927\u5bb6\u5728.NET\u4e2d\u4f7f\u7528Consul\u8fdb\u884c\u670d\u52a1\u6ce8\u518c\u4e0e\u53d1\u73b0\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[895,3843],"topic":[],"class_list":["post-41735","post","type-post","status-publish","format-standard","hentry","category-server","tag-net","tag-consul"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>.net consul\u670d\u52a1\u6ce8\u518c\u4e0e\u53d1\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/41735.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\".net consul\u670d\u52a1\u6ce8\u518c\u4e0e\u53d1\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb969\u6b21\uff0c\u70b9\u8d5e5\u6b21\uff0c\u6536\u85cf6\u6b21\u3002\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u6211\u4eec\u53ef\u4ee5\u5728.NET Core\u5e94\u7528\u7a0b\u5e8f\u4e2d\u8f7b\u677e\u5b9e\u73b0\u57fa\u4e8eConsul\u7684\u670d\u52a1\u6ce8\u518c\u4e0e\u53d1\u73b0\u4ee5\u53ca\u914d\u7f6e\u7ba1\u7406\u3002Consul\u7684\u5f3a\u5927\u529f\u80fd\u4e3a\u5fae\u670d\u52a1\u67b6\u6784\u7684\u6784\u5efa\u63d0\u4f9b\u4e86\u6709\u529b\u652f\u6301\uff0c\u80fd\u591f\u5e2e\u52a9\u6211\u4eec\u6784\u5efa\u66f4\u52a0\u7a33\u5b9a\u3001\u9ad8\u6548\u7684\u5206\u5e03\u5f0f\u7cfb\u7edf\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u9700\u6c42\u5bf9\u670d\u52a1\u6ce8\u518c\u548c\u53d1\u73b0\u7684\u903b\u8f91\u8fdb\u884c\u4f18\u5316\u548c\u6269\u5c55\uff0c\u4ee5\u6ee1\u8db3\u4e0d\u540c\u7684\u4e1a\u52a1\u573a\u666f\u3002\u5e0c\u671b\u672c\u6587\u80fd\u5bf9\u5927\u5bb6\u5728.NET\u4e2d\u4f7f\u7528Consul\u8fdb\u884c\u670d\u52a1\u6ce8\u518c\u4e0e\u53d1\u73b0\u6709\u6240\u5e2e\u52a9\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/41735.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-06-03T19:23:51+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/41735.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/41735.html\",\"name\":\".net consul\u670d\u52a1\u6ce8\u518c\u4e0e\u53d1\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-06-03T19:23:51+00:00\",\"dateModified\":\"2025-06-03T19:23:51+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/41735.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/41735.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/41735.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\".net consul\u670d\u52a1\u6ce8\u518c\u4e0e\u53d1\u73b0\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":".net consul\u670d\u52a1\u6ce8\u518c\u4e0e\u53d1\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/41735.html","og_locale":"zh_CN","og_type":"article","og_title":".net consul\u670d\u52a1\u6ce8\u518c\u4e0e\u53d1\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb969\u6b21\uff0c\u70b9\u8d5e5\u6b21\uff0c\u6536\u85cf6\u6b21\u3002\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u6211\u4eec\u53ef\u4ee5\u5728.NET Core\u5e94\u7528\u7a0b\u5e8f\u4e2d\u8f7b\u677e\u5b9e\u73b0\u57fa\u4e8eConsul\u7684\u670d\u52a1\u6ce8\u518c\u4e0e\u53d1\u73b0\u4ee5\u53ca\u914d\u7f6e\u7ba1\u7406\u3002Consul\u7684\u5f3a\u5927\u529f\u80fd\u4e3a\u5fae\u670d\u52a1\u67b6\u6784\u7684\u6784\u5efa\u63d0\u4f9b\u4e86\u6709\u529b\u652f\u6301\uff0c\u80fd\u591f\u5e2e\u52a9\u6211\u4eec\u6784\u5efa\u66f4\u52a0\u7a33\u5b9a\u3001\u9ad8\u6548\u7684\u5206\u5e03\u5f0f\u7cfb\u7edf\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u9700\u6c42\u5bf9\u670d\u52a1\u6ce8\u518c\u548c\u53d1\u73b0\u7684\u903b\u8f91\u8fdb\u884c\u4f18\u5316\u548c\u6269\u5c55\uff0c\u4ee5\u6ee1\u8db3\u4e0d\u540c\u7684\u4e1a\u52a1\u573a\u666f\u3002\u5e0c\u671b\u672c\u6587\u80fd\u5bf9\u5927\u5bb6\u5728.NET\u4e2d\u4f7f\u7528Consul\u8fdb\u884c\u670d\u52a1\u6ce8\u518c\u4e0e\u53d1\u73b0\u6709\u6240\u5e2e\u52a9\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/41735.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-06-03T19:23:51+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/41735.html","url":"https:\/\/www.wsisp.com\/helps\/41735.html","name":".net consul\u670d\u52a1\u6ce8\u518c\u4e0e\u53d1\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-06-03T19:23:51+00:00","dateModified":"2025-06-03T19:23:51+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/41735.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/41735.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/41735.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":".net consul\u670d\u52a1\u6ce8\u518c\u4e0e\u53d1\u73b0"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/41735","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=41735"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/41735\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=41735"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=41735"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=41735"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=41735"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}