.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Do Membership Roles work with custom connection string?

Posted By:      Posted Date: October 18, 2010    Points: 0   Category :ASP.Net

Hi all, plz help with one issue.
I have Membership configured with IIS7, tables for it located in my own database, created with aspnet_regsql utility, and I am using custom connection string to access it.

This is part of web.config related to Membership :

        <add connectionString="Server=CORESERVER\SQLExpress;Database=Shop;User ID=Tema;Password=Matrix" name="CustomSqlConnection" />
    <profile enabled="true">
            <add name="CustomSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="CustomSqlConnection" />
    <roleManager defaultProvider="AspNetSqlRoleProvider" enabled="true">
            <add name="CustomSqlRoleProvider" type="System.Web.Security.SqlRoleProvider, System.Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="CustomSqlConnection" />
    <membership defaultProvider="CustomSqlMemberPr

View Complete Post

More Related Resource Links

write Custom MemberShip provdider only to read the connection string from other file

hi,    In asp.net mvc project I am using MYSQlMemberShipProvider. Now I want that instead of reading the connection string from web.config file, it will read the connection string from external file every time. So that I am implementing the cutsom mebership provider class, this class inherits the MemberShipProvider class.    But the problem is that if I inherits the MemberShipProvider class then I have to impelment all of its method in my cutsom membership provider class, But I want to use all other inbuilt methods of MemeberShip. What can i do.I only want to add the code like below: public class CustomSqlMembershipProvider :MembershipProvider    {        public override void Initialize(string name, NameValueCollection configs)        {            base.Initialize(name, configs);                Connectionstring objProducts = // redaing the connection string.   }}But on compiltaion it is giving me the error does not implement inherit abstract member. Please Suggest me any idea.        Thanks In AdanaceAayushi

Custom security via connection string

Hi Is it possible to pass information into the SQL Server relational engine via the connection string in the same way as it can be done for Analysis Services? I need to generate a user context for a forms authentication application (i.e. no windows user accounts). SSAS allows you to pass in a list of database roles or a customdata parameter on the connection string. These can be used inside the database in lieu of a windows identity. I am wondering if there are equivalent parameters available for the SQL connection string.  I guess that I could create SQL logins from each of the forms users with a system generated password and then pass the uid and password on the connection string but this seems unnecessarily complicated. Andrew Wiles - www.it-workplace.com - MDX made simple

Setting Membership/Profile/Role provider's connection string at runtime...?


How can I set the connection string for the built-in membership, profile and role providers at runtime?

Since each site in our multi-site application uses a separate API to retrieve its specific connection string (via key, for security purposes), I cannot set the connection string to my providers in the web.config file. I need to be able to set the connection strings programmatically at runtime, but I cannot find how to implement this.

I thought many people must have run into this problem, but I can't seem to find anything regarding this.Can anyone here help me with this problem?



Check the if SSAS Roles property is used in excel connection string before returning the values



We are using Excel 2007 to connect to SSAS cubes. We have many roles for a user and all having different permission including different VISUAL TOTAL setting. We want to restrict the user so that he cannot see anything if he is not using the ROLES property in the excel connection string.

At the run time I want to know if the user who is using excel has used ROLES property or not.

Any help will be appreciated

Mr myName

SQL Connection String

We can learn or know how can we connect the database from our .net. This will help for freshers or .NET beginners!

abstract away the source of the connection string using a class with a static property.

ASP.NET provides a configuration system we can use to keep our applications flexible at runtime. In this article we will examine some tips and best practices for using the configuration system for the best results.

The element of a web.config file is a place to store connection strings, server names, file paths, and other miscellaneous settings needed by an application to perform work. The items inside appSettings are items that need to be configurable depending upon the environment, for instance, any database connection strings will change as you move your application from a testing and staging server into production.

Let's abstract away the source of the connection string using a class with a static property.

connection string question from a newbie


when publishing  in the webmatrix dialogue it asks for "destination connection string" for my "database.mdf"

I was not sure what it was so I pasted this from my web.config file :

Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\database.mdf;Integrated Security=True;User Instance=True

it all published ok, but wont run, so I guess it has somthing to do with this connection string or some kind of configuration issue.

My question is this, What should go in the field for "Destination connection string"

Membership Provider Conn String


Hello. I've bee successfully using the Asp.Net Membership Provider in my VB.Net 3.5/SQL 2005 web app for a year now (Site A). However, I've added 2 new sites (B and C) (both with their own DB) and now I see a problem. It looks like users that get created for sites B and C also get created in site A. Roles that I create for B and C only get created in A. I think it is a conn string problem.

When I created A, I adde the conn string to my machine.config (not sure why I did this or if it is even needed)...


         <add name="LocalSqlServer" connectionString="Data Source=VS689\SQLEXPRESS;Initial Catalog=SiteA;USER ID=sa;PASSWORD=123456"/>


                <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=, Culture=neutral, PublicKeyToken=blahblah" connectionStringName="LocalSqlS

Modifying connection String in Web config using Install Wizard



Im trying to create a Web Deployment Project, the built in setup and deployment is very good in Visual Studio, i need to able to add an additional step in the setup to change the connection string in the Web config file. Ive seen a lot of articles on how to do this and in particular this http://weblogs.asp.net/scottgu/archive/2007/06/15/tip-trick-creating-packaged-asp-net-setup-programs-with-vs-2005.aspx#7162670 I am however stuck on the final part of this tutorial, im using the code Scott provided but have two errors,  heres part of my code where the errors are

using System;
using System.Configuration;
using System.Configuration.Install;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.DirectoryServices;

 void ConfigureDatabase(string targetSite, string targetVDir, string connectionString)
            // Retrieve "Friendly Site Name" from IIS for TargetSite
            DirectoryEntry entry = new DirectoryEntry("IIS://LocalHost/" + targetSit

How in web.config work in MVC



I would like to secure any URL below the http://MyServer/Admins and limit it to a specific role.

In webforms it was straight forward. I just put a child web.config in the /Admin/ folder and add <authorization>  <allow roles> tags to it.

How would be the equivalent technique in MVC?

Thank you,


Implementing a custom Membership Provider vs. using aspnet_Profile table - Which should I do?


I wanted to expand the amount of information that is associated with each user(MembershipUser) in the ASPNETDB.MDF database file. Adding columns like FirstName, LastName, etc. So I began implementing my own custom Membership Provider. I created a derived MembershipUser class with the extra private variables that I wanted each MembershipUser record to store. Its basically done. Almost after I did this I stumbled across the columns in the ASPNETDB.MDF->aspnet_Profile table called "PropertyNames" and "PropertyValuesString".  Could I have simply used these two columns to accomplish what I was attempting to do or are these columns for global application configuration settings?  

Is the aspnet_Profile table purpose to store expanded/related information about users such as personal information? Or is it for something else? Thanks.

FileUpload Control with membership and roles


Hi Everyone!

I'm pretty new to development using Microsoft technologies.

I'm trying to build a portal kind of an application in asp.net, in which one of the functionality is letting people log in and upload their documents. The upload page is only accessible to registered users of the portal.


I would like to track the user uploaded files according to their userIds.

Is it possible to use the FileUpload Control and C# to fetch the current user id, create a directory with the same name(as that of userID) in the file system and upload the files( multiple file upload, if necessary) into it?

Also another admin page would have to be able to see the list of files uploaded by the specific user and download it if necessary.

Could anyone help me with this?

I'm also expecting alternate solutions to the problem.

Awaiting a response.

Thanks in advance 


Adding additional fields to my custom membership provider

Hi, i have been playing around with the membership provider model for the last week and have it got it working with a basic table schema.  The trouble i have is that i wish to add an additional field (eg First Name) but am not sure how i can do this.  Here's what i have so far: public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)    {        MembershipUser user = new MembershipUser(Name, username, providerUserKey, email, passwordQuestion, null, isApproved, false, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now);        string sql = "INSERT INTO USERS(USERNAME,PASSWORD,EMAIL,ISACTIVE) VALUES(@UID,@PWD,@EMAIL,@ISACTIVE)";        db.AddParameter("@UID", username);        db.AddParameter("@PWD", password);        db.AddParameter("@EMAIL", email);        db.AddParameter("@ISACTIVE", (isApproved == true ? "Y" : "N"));        int i = db.ExecuteNonQuery(sql); 

Multiple groups of roles in membership

Hi,I am developing this website which requires multiple groups of roles inside membership.Here is an example:I want to create a group of states (would be the first group of roles):* Oregon* California* Kansas* Texas* OhioAnd then a second group of profiles:* Admin* Section 1* Section 2* Section 3Then I want to comine these groups, so for example:* Patrick has Oregon and Section 1 role, so he can only access the state of Oregon and Section 1 module on the website.* Laura has Kansas and Section 2 role, so she can only access the state of Kansas and Section 2 module on the website.* John has Ohio, Texas and Admin and Section 1 roles, so he can only....Do you understand what I mean? How can I achieve this with .net memberhip?

connection string

on the computer with sql management installed i use this and it works(server name):  .\SQLEXPRESS the computer name is: MAINCOMPUTER2 another computer on the network would use what? i can see  the c drives on either computer from either computer so i am connected.    
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend