将 AzureCosmosDb 连接字符串存储在 web.config 中

Store AzureCosmosDb connection string in web.config

我在 Azure 中创建了一个 AzureCosmosDb 帐户以便使用 MongoDb。

我得到了一个完美运行的连接字符串,但它以 /?ssl=true&replicaSet=globaldb 结尾。所以我无法将它存储在我的 web.config 文件的 connectionStrings 部分。它说:

Entity 'replicaSet' not defined
Expecting ;
Application Configuration file "Web.config" is invalid. '=' is an unexpected token. The expected token is ';'.

我不想将它存储在常量中,所以有没有办法让它工作?

谢谢。

web.config 文件是一个 XML 文件,因此任何值都必须是有效的 XML.

您需要将 & 符号替换为 &:

/?ssl=true&replicaSet=globaldb

这里是similar question.