Saturday, 24 August 2013

Invalid URI error with MongoDB connection string but only when run on Azure? (ASP.NET Web Role)

Invalid URI error with MongoDB connection string but only when run on
Azure? (ASP.NET Web Role)

I have an ASP.NET MVC Web Role that communicates with a remote server
running MongoDB. The connection string has the credentials in it. When I
run the the MVC Web Role on localhost it works fine. However, when I
publish the MVC Web Role to Azure and run it I get the following
error/stack trace:
Invalid URI: There is an invalid sequence in the string.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.UriFormatException:
Invalid URI: There is an invalid sequence in the string.
Source Error:
An unhandled exception was generated during the execution of the current
web request.
Information regarding the origin and location of the exception can be
identified using
the exception stack trace below.
Stack Trace:
[UriFormatException: Invalid URI: There is an invalid sequence in the
string.]
System.Uri.UnescapeString(Char* pStr, Int32 start, Int32 end, Char[]
dest, Int32& destPosition, Char rsvd1, Char rsvd2, Char rsvd3,
UnescapeMode unescapeMode, UriParser syntax, Boolean isQuery, Boolean
readOnlyConfig) +618
System.Uri.UnescapeDataString(String stringToUnescape) +280
MongoDB.Driver.MongoUrlBuilder.Parse(String url) +237
MongoDB.Driver.MongoUrl..ctor(String url) +47
MongoDB.Driver.MongoUrl.Create(String url) +121
MongoDB.Driver.MongoServer.Create(String connectionString) +54
MongoDatabaseWrapper.get_Database() +30
Why would the UnescapeString() method or this stack of calls behave
differently if the code is running on my local PC versus on Azure?

No comments:

Post a Comment