{"id":88,"date":"2010-03-11T20:21:00","date_gmt":"2010-03-11T20:21:00","guid":{"rendered":"http:\/\/wangxianyuan.com\/blogengine\/post\/howto-configuration-webconfig-for-blogproviders"},"modified":"2014-03-22T11:11:24","modified_gmt":"2014-03-22T11:11:24","slug":"howto-configuration-webconfig-for-blogproviders","status":"publish","type":"post","link":"http:\/\/wangxianyuan.com\/blogengine\/post\/howto-configuration-webconfig-for-blogproviders","title":{"rendered":"\u535a\u6613\u535a\u5ba2\u6570\u636e\u5b58\u50a8\u65b9\u5f0f\u7684Web.config\u914d\u7f6e"},"content":{"rendered":"<p>\u535a\u6613\u7684\u6570\u636e\u5b58\u50a8\u652f\u6301 XML \u65e0\u6570\u636e\u5e93\u65b9\u5f0f\uff0c\u4e5f\u652f\u6301 SQL Server\u3001MySQL\u3001VistaDB \u548c SQLite \u7b49\u591a\u79cd\u6570\u636e\u5e93\u3002\u4e0b\u9762\u5c06\u4ecb\u7ecd\u5982\u4f55\u4e0b\u4fee\u6539 Web.config\uff0c\u4ee5\u914d\u7f6e\u535a\u5ba2\u6570\u636e\u5b58\u50a8\u65b9\u5f0f\u3002<br \/>\n\u6253\u5f00 Web.config \u6211\u4eec\u53ef\u4ee5\u627e\u5230 <strong>configurationBlogEngineblogProvider<\/strong> &nbsp;\u8282\u70b9\u3002\u8fd9\u5c31\u662f\u914d\u7f6e\u6570\u636e\u5b58\u50a8\u65b9\u5f0f\u7684\u5730\u65b9\u3002<br \/>\nblogProvider&nbsp;\u8282\u70b9\u4e0b\u8fd8\u6709&nbsp;<strong>providers <\/strong>\u8282\u70b9\uff0c\u4f8b\u5982\u4e0b\u9762\u7684\u914d\u7f6e\u8868\u793a\u5b58\u5728\u4e24\u79cd\u6570\u636e\u5b58\u50a8\u65b9\u5f0f&mdash;&mdash;&nbsp;XmlBlogProvider\u548cDbBlogProvider\u3002<\/p>\n<div>\n<div>\n<div>[code:xml]<\/div>\n<div>&lt;providers&gt;<\/div>\n<div><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t<\/span>&lt;add name=&quot;XmlBlogProvider&quot; type=&quot;BlogEngine.Core.Providers.XmlBlogProvider, BlogEngine.Core&quot;\/&gt;<\/div>\n<div><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t<\/span>&lt;add name=&quot;DbBlogProvider&quot; type=&quot;BlogEngine.Core.Providers.DbBlogProvider, BlogEngine.Core&quot; connectionStringName=&quot;BlogEngine&quot; \/&gt;<\/div>\n<div>&lt;\/providers&gt;<\/div>\n<div>[\/code]<\/div>\n<\/div>\n<div>\u4e0a\u9762 <strong>type<\/strong> \u8868\u793a\u5176\u7c7b\u578b\uff0c\u5982\u679c\u662f\u6570\u636e\u5e93\u7c7b\u578b\u5219\u8fd8\u4f1a\u6709&nbsp;<strong>connectionStringName<\/strong> \u8868\u793a\u6570\u636e\u5e93\u8fde\u63a5\u5b57\u7b26\u4e32\u7684\u540d\u79f0\u3002\u8fd9\u4e2a&nbsp;connectionStringName \u53ea\u662f\u4e00\u4e2a\u540d\u79f0\uff0c\u5176\u503c\u5b58\u5728\u4e8e&nbsp;<strong>configurationconnectionStrings<\/strong> \u8282\u70b9\u4e0b\u3002\u4f8b\u5982\u4e0b\u9762\u7684\u914d\u7f6e\u8868\u793a\u540d\u79f0\u4e3a&nbsp;BlogEngine \u7684\u6570\u636e\u5e93\u8fde\u63a5\u5b57\u7b26\u4e32\u4e3a&nbsp;Data Source=MySQLServer;User ID=user;Password=password;persist security info=False;initial catalog=BlogYi\u3002<\/p>\n<div>\n<div>[code:xml]<\/div>\n<div>&lt;connectionStrings&gt;<\/div>\n<div><span class=\"Apple-tab-span\" style=\"white-space:pre\">\t<\/span>&lt;add name=&quot;BlogEngine&quot; connectionString=&quot;Data Source=MySQLServer;User ID=user;Password=password;persist security info=False;initial catalog=BlogYi;&quot; providerName=&quot;System.Data.SqlClient&quot;\/&gt;<\/div>\n<div>&lt;\/connectionStrings&gt;<\/div>\n<div>[\/code]<\/div>\n<\/div>\n<div>\u56e0\u6b64\uff0c\u5982\u679c\u5728&nbsp;<strong>providers <\/strong>\u8282\u70b9\u4e0b\u914d\u7f6e\u4e86\u6570\u636e\u5e93\u4f5c\u4e3a\u6570\u636e\u5b58\u50a8\u65b9\u5f0f\uff0c\u5219\u4e00\u5b9a\u8981\u5728&nbsp;<strong>connectionStrings <\/strong>\u8282\u70b9\u4e0b\u914d\u7f6e\u76f8\u5e94\u7684\u6570\u636e\u5e93\u8fde\u63a5\u5b57\u7b26\u4e32\uff1b\u800c\u5982\u679c\u6ca1\u6709\u7528\u6570\u636e\u5e93\u4f5c\u4e3a\u6570\u636e\u5b58\u50a8\u65b9\u5f0f\uff0c\u5219\u53ef\u7701\u53bb&nbsp;connectionStrings \u8282\u70b9\u4e0b\u7684\u914d\u7f6e\u3002<\/p>\n<p>\u867d\u7136\u535a\u6613\u652f\u6301\u591a\u79cd\u6570\u636e\u5b58\u50a8\u65b9\u5f0f\uff0c\u4f46\u662f\u5f53\u524d\u6709\u6548\u7684\u6570\u636e\u5b58\u50a8\u65b9\u5f0f\u662f\u552f\u4e00\u7684\u3002\u4e0a\u9762\u4ecb\u7ecd\u4e86\u5982\u4f55\u914d\u7f6e\u5404\u79cd\u6570\u636e\u5b58\u50a8\u65b9\u5f0f\uff0c\u90a3\u4e48\u5982\u4f55\u4e3a\u5f53\u524d\u6709\u6548\u4f7f\u7528\u7684\u6570\u636e\u5e93\u5b58\u50a8\u65b9\u5f0f\u5462\uff1f\u8bf7\u627e\u5230&nbsp;<strong>configurationBlogEngineblogProvider <\/strong>\u8282\u70b9\u3002\u6709\u5c5e\u6027 defaultProvider\uff0c\u8be5\u5c5e\u6027\u8868\u793a\u5f53\u524d\u9ed8\u8ba4\u7684\u6570\u636e\u5b58\u50a8\u65b9\u5f0f\u540d\u79f0\uff0c\u8fd9\u4e2a\u540d\u79f0\u4e5f\u5c31\u662f\u4e0a\u9762&nbsp;<strong>providers&nbsp;<\/strong>\u8282\u70b9\u91cc\u9762\u914d\u7f6e\u7684\u5404\u9879\u7684 name \u5c5e\u6027\u3002\u5982\uff1a<\/div>\n<div>\n<div>[code:xml]<\/div>\n<div>&lt;blogProvider defaultProvider=&quot;XmlBlogProvider&quot;&gt;<\/div>\n<div>[\/code]<\/div>\n<p>\u8868\u793a\u5f53\u524d\u9ed8\u8ba4\u4f7f\u7528\u7684\u6570\u636e\u5b58\u50a8\u65b9\u5f0f\u4e3a XML \u65e0\u6570\u636e\u5e93\u65b9\u5f0f\u3002<\/p>\n<p>\u53e6\u5916\uff0c\u5bf9\u4e8eMySQL\u3001VistaDB \u548c SQLite \u7b49\u6570\u636e\u5e93\u5b58\u50a8\u65b9\u5f0f\uff0c\u5b89\u88c5\u5305\u4e2d\u6709\u76f8\u5e94\u7684 web.config \u6587\u4ef6\uff0c\u5982\u679c\u5728\u8fd9\u4e9b\u6587\u4ef6\u7684\u57fa\u7840\u4e0a\u914d\u7f6e\uff0c\u5c06\u4f1a\u66f4\u52a0\u7b80\u5355\u65b9\u4fbf\u3002<\/p><\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u535a\u6613\u7684\u6570\u636e\u5b58\u50a8\u652f\u6301 XML \u65e0\u6570\u636e\u5e93\u65b9\u5f0f\uff0c\u4e5f\u652f\u6301 SQL Server\u3001MySQL\u3001VistaDB \u548c SQLite \u7b49\u591a\u79cd\u6570\u636e\u5e93\u3002\u4e0b\u9762\u5c06\u4ecb\u7ecd\u5982\u4f55\u4e0b\u4fee\u6539 Web.config\uff0c\u4ee5\u914d\u7f6e\u535a\u5ba2\u6570\u636e\u5b58\u50a8\u65b9\u5f0f\u3002 \u6253\u5f00 Web.config \u6211\u4eec\u53ef\u4ee5\u627e\u5230 configurationBlogEngineblogProvider &nbsp;\u8282\u70b9\u3002\u8fd9\u5c31\u662f\u914d\u7f6e\u6570\u636e\u5b58\u50a8\u65b9\u5f0f\u7684\u5730\u65b9\u3002 blogProvider&nbsp;\u8282\u70b9\u4e0b\u8fd8\u6709&nbsp;providers \u8282\u70b9\uff0c\u4f8b\u5982\u4e0b\u9762\u7684\u914d\u7f6e\u8868\u793a\u5b58\u5728\u4e24\u79cd\u6570\u636e\u5b58\u50a8\u65b9\u5f0f&mdash;&mdash;&nbsp;XmlBlogProvider\u548cDbBlogProvider\u3002 [code:xml] &lt;providers&gt; &lt;add name=&quot;XmlBlogProvider&quot; type=&quot;BlogEngine.Core.Providers.XmlBlogProvider, BlogEngine.Core&quot;\/&gt; &lt;add name=&quot;DbBlogProvider&quot; type=&quot;BlogEngine.Core.Providers.DbBlogProvider, BlogEngine.Core&quot; connectionStringName=&quot;BlogEngine&quot; \/&gt; &lt;\/providers&gt; [\/code] \u4e0a\u9762 type \u8868\u793a\u5176\u7c7b\u578b\uff0c\u5982\u679c\u662f\u6570\u636e\u5e93\u7c7b\u578b\u5219\u8fd8\u4f1a\u6709&nbsp;connectionStringName \u8868\u793a\u6570\u636e\u5e93\u8fde\u63a5\u5b57\u7b26\u4e32\u7684\u540d\u79f0\u3002\u8fd9\u4e2a&nbsp;connectionStringName \u53ea\u662f\u4e00\u4e2a\u540d\u79f0\uff0c\u5176\u503c\u5b58\u5728\u4e8e&nbsp;configurationconnectionStrings \u8282\u70b9\u4e0b\u3002\u4f8b\u5982\u4e0b\u9762\u7684\u914d\u7f6e\u8868\u793a\u540d\u79f0\u4e3a&nbsp;BlogEngine \u7684\u6570\u636e\u5e93\u8fde\u63a5\u5b57\u7b26\u4e32\u4e3a&nbsp;Data Source=MySQLServer;User ID=user;Password=password;persist security info=False;initial catalog=BlogYi\u3002 [code:xml] &lt;connectionStrings&gt; &lt;add name=&quot;BlogEngine&quot; connectionString=&quot;Data Source=MySQLServer;User ID=user;Password=password;persist security info=False;initial catalog=BlogYi;&quot; providerName=&quot;System.Data.SqlClient&quot;\/&gt; &lt;\/connectionStrings&gt; [\/code] [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[24,28,19,27,23],"class_list":["post-88","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-config","tag-database","tag-v1-9","tag-27","tag-23"],"_links":{"self":[{"href":"http:\/\/wangxianyuan.com\/blogengine\/wp-json\/wp\/v2\/posts\/88","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/wangxianyuan.com\/blogengine\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/wangxianyuan.com\/blogengine\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/wangxianyuan.com\/blogengine\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/wangxianyuan.com\/blogengine\/wp-json\/wp\/v2\/comments?post=88"}],"version-history":[{"count":1,"href":"http:\/\/wangxianyuan.com\/blogengine\/wp-json\/wp\/v2\/posts\/88\/revisions"}],"predecessor-version":[{"id":131,"href":"http:\/\/wangxianyuan.com\/blogengine\/wp-json\/wp\/v2\/posts\/88\/revisions\/131"}],"wp:attachment":[{"href":"http:\/\/wangxianyuan.com\/blogengine\/wp-json\/wp\/v2\/media?parent=88"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wangxianyuan.com\/blogengine\/wp-json\/wp\/v2\/categories?post=88"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wangxianyuan.com\/blogengine\/wp-json\/wp\/v2\/tags?post=88"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}