我正在将 asp.net 成员资格升级到 MVC4 中新的 simplemembership 提供程序。这是一个 Azure/Sql Azure 应用程序,它在 localhost 上运行良好,但在部署时失败。我在事务中有如下代码:
TransactionOptions toptions = new TransactionOptions();
toptions.IsolationLevel = System.Transactions.IsolationLevel.Serializable;
using (TransactionScope trans = new TransactionScope(TransactionScopeOption.Required, toptions))
{
try
{
... do a bunch of database stuff in a single dbContext ...
var roleprov = (SimpleRoleProvider)Roles.Provider;
string[] roles = roleprov.GetRolesForUser(Username);
// above line fails with The transaction manager has disabled its support for remote/network transactions. (Exception from HRESULT: 0x8004D024)
}
}
我正在使用这种技术来填充角色类。堆栈跟踪似乎表明它确实在尝试触发子事务以完成该调用。simplemembership 表位于不同的数据库中。如何在单独事务的上下文中从角色提供者检索角色信息?