在mongodb连接字符串中处理@ [英] handle @ in mongodb connection string
问题描述
我有连接字符串
<add key="MongoDBConnectionString" value="mongodb://user:password@123@127.0.0.1/?safe=true"/>
密码为password@123
,因此主机正在解析123@127.0.0.1,我该如何处理凭据中的@
password is password@123
so host is parsing 123@127.0.0.1, how can i handle @ in credential
修改 我试图逃脱它,但仍然是同样的问题
Edit I have tried to escape it but still same problem
<add key="MongoDBConnectionString" value="mongodb://user:password@123@127.0.0.1/?safe=true"/>
修改 感谢alexjamesbrown为我逃避工作后的帮助.
Edit Thanks to alexjamesbrown for helping, following escaping working for me.
<add key="MongoDBConnectionString" value="mongodb://user:password%40123@127.0.0.1/?safe=true"/>
推荐答案
我之前将其发布为答案,但将其转换为评论...
I posted this as an answer before, but it converted it to a comment...
将@符号转至%40
(在您的密码字符串中).
Escape your @ sign to %40
(in your password string.)
根据评论,我相信这可以在C#驱动程序下使用,但在使用其他驱动程序(例如,在node.js上使用猫鼬)时可能无法正常工作
As per the comments, I believe this will work using the C# driver, but might not work when using other drivers (mongoose on node.js for example)
这篇关于在mongodb连接字符串中处理@的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!