{"id":28588,"date":"2024-11-25T08:37:34","date_gmt":"2024-11-25T00:37:34","guid":{"rendered":"https:\/\/fwq.ai\/blog\/28588\/"},"modified":"2024-11-25T08:37:34","modified_gmt":"2024-11-25T00:37:34","slug":"c%e5%bc%80%e5%8f%91%e5%be%ae%e4%bf%a1%e5%ae%9e%e7%8e%b0jssdk%e7%ad%be%e5%90%8d%e7%94%9f%e6%88%90","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/28588\/","title":{"rendered":"c#\u5f00\u53d1\u5fae\u4fe1\u5b9e\u73b0jssdk\u7b7e\u540d\u751f\u6210"},"content":{"rendered":"<p>\u8fd9\u7bc7\u6587\u7ae0\u8bb2\u89e3\u7684\u7684\u6bd4\u8f83\u8be6\u7ec6,\u800c\u4e14\u7b97\u6cd5\u51c6\u786e,\u4f46\u662f\u8fd9\u7bc7\u6587\u7ae0\u6709\u51e0\u4e2a\u9519\u8bef\u7684\u5730\u65b9\u9700\u8981\u6ce8\u610f;<\/p>\n<p>url\u5fc5\u987b\u52a8\u6001\u751f\u6210<\/p>\n<p>url\u4e0d\u80fd\u5199\u6b7b,\u5426\u5219\u5c31\u7b97\u7ed3\u679c\u548c\u5b98\u65b9\u68c0\u6d4b\u7684\u4e00\u81f4,\u4e5f\u53ea\u4f1a\u662f\u65e0\u6548\u7684<\/p>\n<pre>string&nbsp;url&nbsp;=&nbsp;Request.Url.ToString();<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>noncestr\u5fc5\u987b\u52a8\u6001\u751f\u6210<\/p>\n<p>noncestr\u4e5f\u662f\u52a8\u6001\u83b7\u53d6\u7684,\u4e0d\u80fd\u5199\u6b7b<\/p>\n<pre>\/\/\/&lt;summary&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/\/\u751f\u6210\u968f\u673a\u5b57\u7b26\u4e32&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/\/&lt;\/summary&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/\/&lt;param&gt;\u76ee\u6807\u5b57\u7b26\u4e32\u7684\u957f\u5ea6\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/\/&lt;param&gt;\u662f\u5426\u5305\u542b\u6570\u5b57\uff0c1=\u5305\u542b\uff0c\u9ed8\u8ba4\u4e3a\u5305\u542b\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/\/&lt;param&gt;\u662f\u5426\u5305\u542b\u5c0f\u5199\u5b57\u6bcd\uff0c1=\u5305\u542b\uff0c\u9ed8\u8ba4\u4e3a\u5305\u542b\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/\/&lt;param&gt;\u662f\u5426\u5305\u542b\u5927\u5199\u5b57\u6bcd\uff0c1=\u5305\u542b\uff0c\u9ed8\u8ba4\u4e3a\u5305\u542b\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/\/&lt;param&gt;\u662f\u5426\u5305\u542b\u7279\u6b8a\u5b57\u7b26\uff0c1=\u5305\u542b\uff0c\u9ed8\u8ba4\u4e3a\u4e0d\u5305\u542b\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/\/&lt;param&gt;\u8981\u5305\u542b\u7684\u81ea\u5b9a\u4e49\u5b57\u7b26\uff0c\u76f4\u63a5\u8f93\u5165\u8981\u5305\u542b\u7684\u5b57\u7b26\u5217\u8868\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/\/&lt;returns&gt;\u6307\u5b9a\u957f\u5ea6\u7684\u968f\u673a\u5b57\u7b26\u4e32&lt;\/returns&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;static&nbsp;string&nbsp;GetRandomString(int&nbsp;length,&nbsp;bool&nbsp;useNum,&nbsp;bool&nbsp;useLow,&nbsp;bool&nbsp;useUpp,&nbsp;bool&nbsp;useSpe,&nbsp;string&nbsp;custom)\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;byte[]&nbsp;b&nbsp;=&nbsp;new&nbsp;byte[4];\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;new&nbsp;System.Security.Cryptography.RNGCryptoServiceProvider().GetBytes(b);\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Random&nbsp;r&nbsp;=&nbsp;new&nbsp;Random(BitConverter.ToInt32(b,&nbsp;0));\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;string&nbsp;s&nbsp;=&nbsp;null,&nbsp;str&nbsp;=&nbsp;custom;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(useNum&nbsp;==&nbsp;true)&nbsp;{&nbsp;str&nbsp;+=&nbsp;\"0123456789\";&nbsp;}\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(useLow&nbsp;==&nbsp;true)&nbsp;{&nbsp;str&nbsp;+=&nbsp;\"abcdefghijklmnopqrstuvwxyz\";&nbsp;}\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(useUpp&nbsp;==&nbsp;true)&nbsp;{&nbsp;str&nbsp;+=&nbsp;\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\";&nbsp;}\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(useSpe&nbsp;==&nbsp;true)&nbsp;{&nbsp;str&nbsp;+=&nbsp;\"!\"#$%&amp;amp;'()*+,-.\/:;?@[\\]^_`{|}~\";&nbsp;}\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;(int&nbsp;i&nbsp;=&nbsp;0;&nbsp;i&nbsp;&lt;p&gt;\u5b98\u65b9\u7ed9\u53d6\u7684\u4f8b\u5b50\u957f\u5ea6\u4e3a16,\u542b\u5927\u5c0f\u5199\u548c\u6570\u5b57,\u6ca1\u6709\u7279\u6b8a\u5b57\u7b26\u4e32&lt;\/p&gt;&lt;p&gt;\u5373&lt;\/p&gt;&lt;pre class=\"brush:c#;toolbar:false\"&gt;var&nbsp;noncestr&nbsp;=&nbsp;GetRandomString(16,&nbsp;true,&nbsp;true,&nbsp;true,&nbsp;false,\"\");<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fc#\u5f00\u53d1\u5fae\u4fe1\u5b9e\u73b0jssdk\u7b7e\u540d\u751f\u6210\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u7bc7\u6587\u7ae0\u8bb2\u89e3\u7684\u7684\u6bd4\u8f83\u8be6\u7ec6,\u800c\u4e14\u7b97\u6cd5\u51c6\u786e,\u4f46\u662f\u8fd9\u7bc7\u6587\u7ae0\u6709\u51e0\u4e2a\u9519\u8bef\u7684\u5730\u65b9\u9700\u8981\u6ce8\u610f; url\u5fc5\u987b\u52a8\u6001\u751f\u6210 url\u4e0d\u80fd\u5199\u6b7b,\u5426\u5219\u5c31\u7b97\u7ed3\u679c\u548c\u5b98\u65b9\u68c0\u6d4b\u7684\u4e00\u81f4,\u4e5f\u53ea\u4f1a\u662f\u65e0\u6548\u7684 string&nbsp;url&nbsp;=&nbsp;Request.Url.ToString(); \u767b\u5f55\u540e\u590d\u5236 noncestr\u5fc5\u987b\u52a8\u6001\u751f\u6210 noncestr\u4e5f\u662f\u52a8\u6001\u83b7\u53d6\u7684,\u4e0d\u80fd\u5199\u6b7b \/\/\/&lt;summary&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/\/\u751f\u6210\u968f\u673a\u5b57\u7b26\u4e32&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/\/&lt;\/summary&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/\/&lt;param&gt;\u76ee\u6807\u5b57\u7b26\u4e32\u7684\u957f\u5ea6 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/\/&lt;param&gt;\u662f\u5426\u5305\u542b\u6570\u5b57\uff0c1=\u5305\u542b\uff0c\u9ed8\u8ba4\u4e3a\u5305\u542b &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/\/&lt;param&gt;\u662f\u5426\u5305\u542b\u5c0f\u5199\u5b57\u6bcd\uff0c1=\u5305\u542b\uff0c\u9ed8\u8ba4\u4e3a\u5305\u542b &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/\/&lt;param&gt;\u662f\u5426\u5305\u542b\u5927\u5199\u5b57\u6bcd\uff0c1=\u5305\u542b\uff0c\u9ed8\u8ba4\u4e3a\u5305\u542b &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/\/&lt;param&gt;\u662f\u5426\u5305\u542b\u7279\u6b8a\u5b57\u7b26\uff0c1=\u5305\u542b\uff0c\u9ed8\u8ba4\u4e3a\u4e0d\u5305\u542b &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/\/&lt;param&gt;\u8981\u5305\u542b\u7684\u81ea\u5b9a\u4e49\u5b57\u7b26\uff0c\u76f4\u63a5\u8f93\u5165\u8981\u5305\u542b\u7684\u5b57\u7b26\u5217\u8868 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/\/&lt;returns&gt;\u6307\u5b9a\u957f\u5ea6\u7684\u968f\u673a\u5b57\u7b26\u4e32&lt;\/returns&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;static&nbsp;string&nbsp;GetRandomString(int&nbsp;length,&nbsp;bool&nbsp;useNum,&nbsp;bool&nbsp;useLow,&nbsp;bool&nbsp;useUpp,&nbsp;bool&nbsp;useSpe,&nbsp;string&nbsp;custom) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;byte[]&nbsp;b&nbsp;=&nbsp;new&nbsp;byte[4]; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;new&nbsp;System.Security.Cryptography.RNGCryptoServiceProvider().GetBytes(b); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Random&nbsp;r&nbsp;=&nbsp;new&nbsp;Random(BitConverter.ToInt32(b,&nbsp;0)); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;string&nbsp;s&nbsp;=&nbsp;null,&nbsp;str&nbsp;=&nbsp;custom; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(useNum&nbsp;==&nbsp;true)&nbsp;{&nbsp;str&nbsp;+=&nbsp;&#8220;0123456789&#8221;;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(useLow&nbsp;==&nbsp;true)&nbsp;{&nbsp;str&nbsp;+=&nbsp;&#8220;abcdefghijklmnopqrstuvwxyz&#8221;;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(useUpp&nbsp;==&nbsp;true)&nbsp;{&nbsp;str&nbsp;+=&nbsp;&#8220;ABCDEFGHIJKLMNOPQRSTUVWXYZ&#8221;;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(useSpe&nbsp;==&nbsp;true)&nbsp;{&nbsp;str&nbsp;+=&nbsp;&#8220;!&#8221;#$%&amp;amp;'()*+,-.\/:;?@[\\]^_`{|}~&#8221;;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;(int&nbsp;i&nbsp;=&nbsp;0;&nbsp;i&nbsp;&lt;p&gt;\u5b98\u65b9\u7ed9\u53d6\u7684\u4f8b\u5b50\u957f\u5ea6\u4e3a16,\u542b\u5927\u5c0f\u5199\u548c\u6570\u5b57,\u6ca1\u6709\u7279\u6b8a\u5b57\u7b26\u4e32&lt;\/p&gt;&lt;p&gt;\u5373&lt;\/p&gt;&lt;pre class=&#8221;brush:c#;toolbar:false&#8221;&gt;var&nbsp;noncestr&nbsp;=&nbsp;GetRandomString(16,&nbsp;true,&nbsp;true,&nbsp;true,&nbsp;false,&#8221;&#8221;); \u767b\u5f55\u540e\u590d\u5236 \u4ee5\u4e0a\u5c31\u662fc#\u5f00\u53d1\u5fae\u4fe1\u5b9e\u73b0jssdk\u7b7e\u540d\u751f\u6210\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-28588","post","type-post","status-publish","format-standard","hentry","category-19"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28588","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=28588"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28588\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=28588"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=28588"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=28588"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}