Posted on: 5/30/2011 4:06:23 AM | Views : 457

Hi, just wondering if anyone knows why I can't do the following. Firstly, I am trying to add a new user to a Role in my membership database. I have a RolesManager.aspx and RolesManager.aspx.cs, this works fine, I can add / delete Roles, add users to Roles and remove from a Role. But, and here's the question, why can't I use the same code in my WebHandler (public class NotifyUrl : IHttpHandler {...})? The code is the same, as follows: System.Web.Security.Roles.AddUserToRole(UserName, "Subs"); // UserName is a String. The error I get is "System.Web.HttpException: Unable to connect to SQL Server database. ---> System.Web.HttpException: Unable to connect to SQL Server database." But the same line of code is working in my RolesManager.aspx.cs page. How does it know where to look for the membership database on the server, is it in my web.config file? p.s. why doesn't this Messsage get posted with my line breaks / line spacing / carrige returns?? ...

Go to the complete details ...