ASP.NET web.config missing membership provider

Hi experts,

Using a tutorial wanted to use the built in Membership function in asp.net.
So I started a new asp.net web application project.
But in my web.config file there is no membership provider defined. I expected the ASPNETSqlMembershipProvider to be there initially.

What do I have to do, so this information is always provided?

Thanks
arthrexAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
guru_samiConnect With a Mentor Commented:
--->Did I understand the tutorial wrong, and you always have to add the AspNetSqlMembershipProvider (with the whole type attribute) manually, or is there really a mechanism that automatically adds this to my web.config?

No you don't have to add it manually because the default settings are taken from your machine.config.
But it is good practice to have it copied in your web.config so those settings remain confined to your application only. Moreover if you are going to use external host provider then it will take up those settings from machine.config of host server, which is not a good idea.
One other thing you might want to note is LocalSqlServer connectionstring in your machine.config. In almost all cases you are going to override this in your web.config. So that's another reason where you would like to change connectionStringName attribute value of membership provider.
0
 
rdogmartinCommented:
Let me see if I understand this. You want to configure the web.config template so that each time you create a new web app it is pre-configured with some default membership stuff. Is that right?

Not sure if this is possible but couldn't you just paste in some boiler plate code you keep handy? First look on the internet for the initial code, then keep it in your own template file.

Also note that in VS 2010 the project template for new ASP.NET apps *do* include membership pre-configured, so if you can move to that you are all set (due to be released within the next few weeks).

Roger
0
 
arthrexAuthor Commented:
Thanks for the answer.
The thing is, I followed a tutorial which makes use of the Membership Server Controls. And it seemed to me, that when I follow the steps, the membership part in the web.config will automatically added.
But I had to do it manually.
Did I understand the tutorial wrong, and you always have to add the AspNetSqlMembershipProvider (with the whole type attribute) manually, or is there really a mechanism that automatically adds this to my web.config?
0
 
rdogmartinCommented:
Every time I have added membership functionality to a web site I have always done it manually (that is, pasting it from elsewhere). I could be wrong but I don't think there is any mechanism in VS 2008 or earlier where it is automatically added for you.

Roger
0
 
arthrexAuthor Commented:
Perfect answer Sami!
The answer was the machine.config file.
There the AspNetSqlMembershipProvider was defined, but the localSqlServerName Attribute was wrong. Therefore I had to override that manually in my webconfig.
0
All Courses

From novice to tech pro — start learning today.