Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers

I helped out a few folks last night on the ASP.NET Forums with this problem, so I thought it might make sense to turn this into a blog post to help share information about this.

 

Scenario:

 

You develop an ASP.NET 2.0 application locally using the new ASP.NET 2.0 Membership, Roles or Profile features.  You create several new users and everything works fine.

 

You then copy the application to a remote server (or even another directory on your local server) and run the application.  For some reason it appears that you are able to connect to your membership database just fine – but when you try to login it doesn’t let you.  It doesn’t throw a connection error, but rather when you attempt to login you get an error message that says something like: “Login attempt unsuccessful, please try again.”

 

Cause:

 

The reason this usually happens is because a membership (or roles or profile) provider has been added in the application’s web.config file – but without an applicationName attribute being specified (assume below that the applicationName in bold was missing):

 

      <membership>

            <providers>

                <clear/>

                <add name="AspNetSqlMembershipProvider"

                    type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"

                    connectionStringName="LocalSqlServer"

                    enablePasswordRetrieval="false"

                    enablePasswordReset="true"

                    requiresQuestionAndAnswer="true"

  requiresUniqueEmail="false"

                    passwordFormat="Hashed"

                    maxInvalidPasswordAttempts="5"

                    minRequiredPasswordLength="7"

                    minRequiredNonalphanumericCharacters="1"

                    passwordAttemptWindow="10"

                    passwordStrengthRegularExpression=""

                    applicationName="/"

                />

            </providers>

      </membership>

 

When no applicationName attribute is configured, ASP.NET uses the application vroot path within the web-server to automatically calculate the applicationName to use when adding data to an ASP.NET Application Service database.  To see this in action, you can open up your ASPNETDB database, and look within the aspnet_Applications table:

 

 

This table stores a unique ApplicationID for each applicationName.  Because I didn’t specify an “applicationName” attribute when I registered users within my application, it calculated the application name as /website8 (which happened to be the name my dev machine was using at the time).

 

Users created with the membership API will then be associated with this ApplicationID and in turn the applicationName.  You can see this by opening up the aspnet_Users table:

 

 

This works fine when the application continues to run in the “/WebSite8” application virtual path.  But if it is copied to another location or server with a different virtual path (for example: “/app1” or more commonly just "/"), then when the Membership APIs are used they will not “see” the users already in our database – since they will lookup membership data using a different application name and filter the users in the application_Users table accordingly.  That is why you’ll get a “Login attempt unsuccessful, please try again.” message when you try to login.

 

How to Solve This

 

The easiest way to solve this is to open up the aspnet_Users and aspnet_Applications tables within the ASPNETDB database and figure out what application name was used when creating the users and other data during development (look in the aspnet_Application table to work this out).

 

You can then go back to your web.config file, and add an “applicationName” attribute to your provider declaration with that application name value.  For example, note how the applicationName value below is now the same as the one in the aspnet_Application table:

 

      <membership>

            <providers>

                <clear/>

                <add name="AspNetSqlMembershipProvider"

                    type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"

                    connectionStringName="LocalSqlServer"

                    enablePasswordRetrieval="false"

                    enablePasswordReset="true"

                    requiresQuestionAndAnswer="true"

  requiresUniqueEmail="false"

                    passwordFormat="Hashed"

                    maxInvalidPasswordAttempts="5"

                    minRequiredPasswordLength="7"

                    minRequiredNonalphanumericCharacters="1"

                    passwordAttemptWindow="10"

                    passwordStrengthRegularExpression=""

                    applicationName="/website8"

                />

            </providers>

      </membership>

 

When the applicationName is set like above, the Membership API will always use that application name when connecting to the ASP.NET application service database.  That means it will work regardless of where the application is deployed or what path is used.

 

You should also then make sure that you do this for any Roles, Profile, WebPartPersonalization or other providers you configure.

 

Your application will then work fine.

 

How to Prevent This in the First Place

 

The best way to prevent this from ever happening is to always specify the “applicationName” attribute when declaring your providers.  One good default value to use is “/” – which is the root application name.  This is the value specified for the default provider that ships with ASP.NET 2.0 (which by default stores the application service data within the ASPNETDB.MDF file under /app_data), and is why if you don’t override the provider settings it will work if you copy an app to another machine.

 

For other ASP.NET Security Links and Resources please check out (and bookmark) this large post of content I did.

 

Hope this helps,

 

Scott

 

P.S. In case it isn’t obvious, the reason why the applicationName setting even exists in the first place is so that you can map multiple applications and sites to the same database.

 

P.P.S. In hindsight, we should have defaulted the provider collection to have a value of "/" for applicationName if it wasn't specified.

Published Saturday, April 22, 2006 9:49 AM by ScottGu
Filed under: ,

Comments

# re: Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers

Saturday, April 22, 2006 2:28 PM by Scott Mitchell
Thanks for posting this, Scott. This has been on my TODO list for blogging about, as it's a common problem for students of mine when moving assignments from the lab computers to their home computers.

# re: Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers

Sunday, April 23, 2006 12:41 AM by Doug Thomas
Scott,

You really bailed me out on this - THANKS

D Thomas

# re: Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers

Sunday, April 23, 2006 3:16 PM by Koistya `Navin
Good tip! Thanks for posting.

# re: Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers

Sunday, April 23, 2006 11:49 PM by vic
I found this out the hard way! Lots of hair pulling! Thanks for making it known!

# re: Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers

Monday, April 24, 2006 7:28 AM by Zack Jones
I wish this blog would have been out a couple of weeks ago. It would have saved me several frustrating hours trying to figure out why I couldn't log in. Thanks for this and all of the great info you've been sharing.

# re: Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers

Monday, April 24, 2006 10:56 AM by Jiv
Yeah - this post came 2 days too late for me :) .... had this problem, and worse in my case i had specified the app name for membership provider and not the roles provider. You can imagine the chaos. But a peep into the database solved it for me.

# re: Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers

Monday, April 24, 2006 6:11 PM by Ronnie
you da man!

# re: Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers

Monday, April 24, 2006 10:26 PM by Ed
Yup, it's the little things that get you.

The more I get into 2.0, it seems that a lot of the new features have some give/take gotchas that need a tip "directory" :)

1) CreateUserWizard
- Give: cool if default feature is good enough
- Take: Try referencing any of the controls, say to add an attribute (ie. client side jscript).

Tip: http://p2p.wrox.com/topic.asp?TOPIC_ID=41084

2) DetailsView/GridView/FormView
- Give: same as above, really cool if you don't need much
- Take: try referencing the controls same as above, try validation on texboxes (this one is really bad) in edit mode. Unless you convert *all* default columns/rows into templates, I can't get this essential function (input validation via validation controls, and/or adding attributes) to work. You could do it by checking e.NewValues, but it seems counter-intuitive, and goes against the normal "grain" of ASP.Net style validation....

DetailsView referencing tip:
myDetailsView.Rows(therowindex).FindControl(thestringID)

3) Roles/Membership/Profile
- Give: awesome
- Take: why aren't these datasources (say for the above controls)? You can access an XML file, Access db, sql, your own DAL/business object, but not these? So I end up writing my own DAL/business object to fully utilize these features...and find out that I've basically almost duplicated my 1.1 code....unless I totally missed the boat on an easy way of doing this...

Ed

# re: Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers

Thursday, April 27, 2006 11:07 AM by Oussama Dinia
Great, very nice. I just recreated the users and roles, I only had 3 for my application. but did not think at all about this property until you posted it. thanks a lot.

# re: Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers

Thursday, April 27, 2006 5:21 PM by steve holstad
Good stuff... I ran into this issue awhile back as well...hopefully everyone see your post in time to help!

http://blogs.claritycon.com/blogs/steve_holstad/archive/2006/02/15/219.aspx

# re: Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers

Friday, April 28, 2006 8:36 PM by scottgu
Hi Ed,

To answer a few of these questions:

#1: You can convert the CreateUserWizard control to be template driven -- which allows you to add client-side javascript.

#2: For GridView and DetailsView you can actually convert individual columns to be templated -- so it is not an all or nothing thing.

#3: You can wrap the Membership API with an ObjectDataSource pretty easily (although I agree it would be cool to have a built-in datasource for them). Peter did this when building his membership/roles admin sample: http://weblogs.asp.net/scottgu/archive/2006/01/09/434925.aspx

Hope this helps,

Scott

# re: Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers

Thursday, May 11, 2006 11:27 AM by Steve Sloka
Your post hit home with me, I am still struggling with getting everything setup. I have specified my applicationName in my "membership", "roleManager", and "profile" sections, yet I still get two applications (the one I specify, and my development appname).

I've seemed to narrow it down to when I add webparts, the second app gets created, is there somewhere else I need to set the app name?

Thanks so much,

~ Steve

# re: Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers

Friday, May 12, 2006 1:03 AM by scottgu
Hi Steve,

There is a <webparts><personalization></webparts> section that you'll want to configure as well to specify the application name. That is the missing provider to configure.

Hope this helps,

Scott

# re: Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers

Thursday, May 18, 2006 6:15 PM by Ryan
I spent two days trying to figure out what was wrong, and this fixed it. THANKS!

# re: Always set the &quot;applicationName&quot; property when configuring ASP.NET 2.0 Membership and other Providers

Friday, June 02, 2006 9:22 PM by Derek
This helped!!! Five days of struggle and this was the answer.... Thanks a million

# re: Always set the &quot;applicationName&quot; property when configuring ASP.NET 2.0 Membership and other Providers

Tuesday, June 06, 2006 12:00 PM by Devaraj
Thanks for posting this important tip...
Sure it will save a lot of time for beginners...

Thx
Dev

# re: Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers

Thursday, June 29, 2006 7:21 AM by Justin

I used the aspnet_regsql.exe to create the required tables and stored procedures onto an exsisting SQL Server 2000 database on a server. I have also created a connectionstring to the database and directed the membership and role providers to point to the database. Now, when I run the web app locally, the login and roles I have created on the web admin tools works fine, but when i upload to web app to the IIS on the server, none of the login and roles seem to work. How can I fix this problem?

# re: Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers

Thursday, June 29, 2006 10:00 PM by ScottGu

Hi Justin,

I'd recommend looking at whether the web-server has access to the SQL server specififed.  In particular, you should look to see whether you are connecting via SQL authentication or Windows Authentication.  My guess is that on your dev box you might be connecting locally via windows authentication -- and when you deploy remotely you can't use windows auth to connect across machines because kerberos isn't enabled.

Hope this helps,

Scott

# re: Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers

Monday, July 03, 2006 9:53 PM by Nik Ivancic

Justin's case as described above is precisely the problem I am trying to solve for a few days already. More precisely, it is not obvious what setup to use on the IIS server which lives in DMZ, and has no means to use Windows authentication to reach the server that runs the SQL 2005.

The SQL 2005 server would happily accept the requests for authentication coming from the "end user" reaching IIS from Internet - but the IIS attempt to get SQL Server 2005 fails before even reaching SQL Server across the network (and through the firewall).

The weird thing is that SQLCMD.exe somehow knows how to do it - it does not help however, since I want my ASP.NET to be able to do that.

I would expect that the described setup is the most common one - the IIS outside firewall and SQL behind. Despite a multi-day search I found no answer. This really indicates that the Semantic Web cannot come too soon :-)

Can you, help, please?

Regards

Nik

# re: Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers

Wednesday, July 05, 2006 11:50 PM by ScottGu

Hi Nik,

I think the issue you are running into is the multi-machine hop when using Windows authentication to connect with the database.

I'm not a windows security expert, but have helped enough people with this question to know that it is a hard one.

I believe this article should help you a little: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/paght000008.asp

Hope this helps,

Scott

# re: Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers

Thursday, July 06, 2006 8:56 AM by Pierre

Hi!

I have the same problem but your solution doesn't seems to work for me. I'll try to explain in detail my problem so maybe you could help me. A couple of days ago a compagny ask me to put their web application on a new server. This server have 3 hard drive and they ask me to put their application alone on an empty hard drive. So i've copied the folder of the application on this hard drive. I also copied all the DB used including the one use for membership. After this i've made the change in the webconfig for my connectionString.

Now when i'm trying to connect i always get this message "Login attempt unsuccessful, please try again.”

My application name is "/" and when i check in the database the same name is use. Do you have an idea of what the problem can be ?

Thanks !!

# re: Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers

Friday, July 07, 2006 2:20 PM by John

I tried all that and it did not work, help please

# re: Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers

Sunday, July 09, 2006 12:42 PM by ScottGu

Hi Pierre,

Can you try creating a new user with the application and then check to see whether you can logout and log back in with that.

If you can, then that verifies that the database is at least working.  

Assuming this is the case, I'd recommend looking in the membership table like i outline above to see what applicationName value is being used.

Hope this helps,

Scott

# re: Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers

Monday, July 10, 2006 8:23 AM by Pierre

Thanks Scott!

I was able to create new user but i was not able to login using those new users. I finally figure out the problem but i do not know the cause. I have delete the login control then i have drop a new one on my page. Since then everything is working fine. When i check the webconfig everything is the same as before and the property of the login control are also the same.

So i do not know what was the problem but now it is working again.

# re: Always set the &quot;applicationName&quot; property when configuring ASP.NET 2.0 Membership and other Providers

Wednesday, July 12, 2006 5:42 PM by Trees
I can not create a new user...... I get an error message......."Failed to update database "C:\INETPUB\WWWROOT\APP_DATA\ASPNETDB.MDF" because the database is read-only."

# re: Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers

Wednesday, July 12, 2006 6:00 PM by ScottGu

Hi Trees,

The problem you are running into is that the IIS worker process account only has read-only access to the file-system.  As such, it can't open the database.

To change this, you should change the file-permissions of the c:\inetpub\wwwroot\app_data directory to have read and write access for the worker process identity.

For IIS5/5.1 set this for the ASPNET account.  For IIS6 set this for the NETWORKSERVICE account.

Hope this helps,

Scott

# re: Always set the &quot;applicationName&quot; property when configuring ASP.NET 2.0 Membership and other Providers

Wednesday, July 12, 2006 6:13 PM by Trees
Changed file-permissions of the c:\inetpub\wwwroot\app_data directory to have read and write access. How do I do this? For IIS5/5.1 set this for the ASPNET account. I do not have an ASPNET account, that I know of?

# re: Always set the &quot;applicationName&quot; property when configuring ASP.NET 2.0 Membership and other Providers

Monday, July 17, 2006 5:58 AM by Amir
Much appreciated. A fairly obvious solution to a problem that has had me tearing my hair out.

# re: Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers

Monday, July 17, 2006 6:55 PM by ScottGu

Hi Trees,

ASP.NET creates an ASPNET account when it is registered on the system.  What you'd want to-do is pull up the file-properties for the directory using the windows explorer, and go into the security tab to control the write permissions on that directory and grant the ASPNET account access.

Hope this helps,

Scott

# re: Always set the &quot;applicationName&quot; property when configuring ASP.NET 2.0 Membership and other Providers

Tuesday, July 18, 2006 1:56 PM by Sylver
Hi Scott, Thanx for bringing this up. It is an apt description of my problem. Unfortunately, your solution has not been able to solve it for me. After reading your piece, i deleted all the users and created new users and roles. I left everything is default state and i'm using the aspnetsqlprovider. The login system works in VWD environment but not with the copy i have on a virtual server on IIS. It's pretty frustrating and can't seem to think of anything else..Can you help??

# re: Always set the &quot;applicationName&quot; property when configuring ASP.NET 2.0 Membership and other Providers

Wednesday, July 19, 2006 2:02 PM by RichDef
Fantastic explanation. I was experiencing this exact problem and after browsing this article I was able to solve it in seconds! Thank You very much!!

# re: Always set the &quot;applicationName&quot; property when configuring ASP.NET 2.0 Membership and other Providers

Wednesday, July 19, 2006 7:20 PM by Jorge Loco
I've been experimenting with applicationName in web.config as part of a general learning process. But I have an interesting problem/note? Let's say I create two apps: /App1 with no applicationName /App2 with the applicationName = "MyApp" Now I create two users User1 in /App1 and User2 in /App2 Now I change web.config in /App1 to include: applicationName = "MyApp" What do I expect? For the list of users in /App1 to say User2 What happens, do you ask? /App1 still lists User1 as its user!?! I've tried stopping starting the web site, removing & adding the Application /App1, but neither work. It seems that some how IIS and/or ASP.Net has permanently mapped /App1 to: applicationName = "" or in other words applicationName = "/App1" Any ideas?

# re: Always set the &quot;applicationName&quot; property when configuring ASP.NET 2.0 Membership and other Providers

Wednesday, July 19, 2006 7:44 PM by Jorge Loco
Sorry to have bothered you... I took a walk, came back and found the solution, though I'm not sure why... Despite closing the browser (IE) it appears that it was caching the page I made to display the users (I'm going to have to look at that page's code to see if I can determine why or attribute it to wierd IE behavior.) Thanks, if you've already looked at it, and thanks for the post it clearly confirmed the behavior I had discovered in my own reading/experimentation. JL

# re: Always set the &quot;applicationName&quot; property when configuring ASP.NET 2.0 Membership and other Providers

Thursday, July 20, 2006 6:43 AM by DinoD
In my dev environment, when I cick start the Site Administration Tool, the only thing I can do for providers management is to "Test" the AspNetSqlProvider option. I can not configure it. There is no "membership" section in my web.config. under which section should it be added in web.config, and what about the BublicKeyToken property, where do I get it from? Thx.

# re: Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers

Saturday, July 22, 2006 12:29 PM by ScottGu

Hi DinoD,

This blog post includes some samples that show how to configure the membership provider: http://odetocode.com/Articles/427.aspx

Hope this helps,

Scott

# re: Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers

Saturday, July 22, 2006 12:30 PM by ScottGu

Hi Sylver,

What error message do you get at runtime when this happens?

It really sounds like the issue might be this one that you are running into.  Can you double check using the steps in my post above that it isn't?

Thanks,

Scott

# Recipe: Implementing Role-Based Security with ASP.NET 2.0 using Windows Authentication and SQL Server

Sunday, July 23, 2006 10:37 PM by ScottGu's Blog

ProblemYou are building an Intranet expense report application for your organization, and want to enable

# re: Always set the &quot;applicationName&quot; property when configuring ASP.NET 2.0 Membership and other Providers

Monday, July 24, 2006 11:16 AM by Parker
Scott, thank you so much for posting this well-explained blog. I'd been working on this problem for three days before reading your blog: it all now works AND I still have some hair left! I do have one question regarding your response to DinoD: the blog you suggest, while very informative, doesn't cover the significance of the PublicTokenKey. I've just left mine as the default value I've seen on all the blogs, i.e. PublicKeyToken=b03f5f7f11d50a3a, but will it always be this value or does it depend on other factors?

# re: Always set the &quot;applicationName&quot; property when configuring ASP.NET 2.0 Membership and other Providers

Monday, July 24, 2006 12:57 PM by Sylver
Hi Scott, The Application doesn't give an error at runtime only that the Login says that "Your login attempt was not successful. Please try again." When i try to log on with credentials that do work in the VWD (Visual Web Development) environment. In other words, it's exactly the problem describe in this your article it's just that your solution doesn't solve it for me even after following all the steps. I even configured the web.config file with the properties set as u highlighted above to no avail. Maybe i'm missing something?! HELP!

# re: Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers

Monday, July 24, 2006 8:44 PM by ScottGu

Hi Parker,

Glad it helped!

I think you can either add or remove the PublicTokenKey -- I don't believe it is necessary.

Hope this helps,

Scott

# re: Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers

Tuesday, July 25, 2006 12:13 AM by ScottGu

Hi Sylver,

Can you .zip up and send me a sample showing the problem?  Either that or just the web.config file for your app?  My email address is: scottgu@microsoft.com

Thanks,

Scott

# ASP.NET 2.0 Tips, Tricks, Recipes and Gotchas

Tuesday, August 01, 2006 11:55 AM by ScottGu's Blog

This page lists some of the more popular &amp;ldquo;ASP.NET 2.0 Tips, Tricks, Recipes and Gotchas&amp;rdquo;

# re: Always set the &quot;applicationName&quot; property when configuring ASP.NET 2.0 Membership and other Providers

Thursday, August 03, 2006 3:24 PM by Andres
Hi, I find your article really interesting but I'm still unable to solve my problem. Here it is: I developed a Custom Membership provider for a Sybase ASE 12.5 database. As this is a single application, I ommited the applicationName field in the user's table. In the ASP.Net development server, the provider works fine, performing log in an so on. The problem arises when the application is moved to the wwwroot (published). The provider accesses the database and retrieves the MembershipUser but for some reason, the Log-in operation does not complete an I get no error message whatsoever. It just performs the Log-In operation but when I try to get the logged in user I always get null. Any Ideas?

# re: Always set the &quot;applicationName&quot; property when configuring ASP.NET 2.0 Membership and other Providers

Thursday, August 03, 2006 5:25 PM by Mukul Agochiya
I am new to website development using .Net Framework 2.0 (asp.net 2.0 ) and have recently used membership controls in my website. I have configured web.config file to allow localsqlserver connection to point to Sql Server 2000. The regsql.exe created membership database in my sql server. My problem is that although I can access the database using website administration tool, but I am unable to logon to my web application using the SQL server 2000 database. Scenario1: Development Database Server and Website is on developer's machine. Here is the error: ************************************************************** An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) 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.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) ************************************************************** I am not using sql server 2005, but still in the error above, it is mentioning about Server 2005. Why? Scenario2: I have also built a new server 2000 but i am not getting any error message but is unable to logon. The above changes to machine.config file and the aspnet_applications table did not help me logon to the (local) database. I have setup new windows 2000 server with .net framework 2.0 and SQL Server 2000 (local server) installed on it. Do I need to install any other software on this test server. Please let me know how to resolve this issue. Your help is deeply appreciated. With thanks, Mukul

# re: Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers

Saturday, August 05, 2006 12:29 PM by ScottGu

Hi Andres,

The issue you are describing actually sounds exactly like the one I listed above.  Can you try setting the applicationName attribute and retrying your scenario again to see if it makes a difference?

Thanks,

Scott

# re: Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers

Saturday, August 05, 2006 12:31 PM by ScottGu

Hi Mukul,

The error message above is actually the standard error message that the ADO.NET API returns when it fails to connect to the database.

Typically this is caused because the user or account accessing the database doesn't have security permissions to-do so.  

Hope this helps,

Scott

# Evítate problemas: pon SIEMPRE un nombre de aplicación en Web.config

El bueno de Scott Guthrie (del equipo de desarrollo de ASp.NET) puso ya hace tiempo un post muy bueno

# re: Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers

Tuesday, August 29, 2006 2:27 PM by Jonathan Lifflander

We had this exact problem and tried changing the application name, but this didn't fix our problem. What finally worked was changing the permissions for Network Service on the actual database ASPNETDB.mdf and the log file to full permissions.

# re: Always set the &quot;applicationName&quot; property when configuring ASP.NET 2.0 Membership and other Providers

Wednesday, August 30, 2006 4:57 PM by Bruce Krasnof
Scott, you rock, I was killing myself over this. Turns out the "/" didn't work for me, but the explicit app name did. Thank you !!!!!!!

# re: Always set the &quot;applicationName&quot; property when configuring ASP.NET 2.0 Membership and other Providers

Thursday, August 31, 2006 5:18 AM by Mark Leonard
I set the application name using the section pasted above. The website renders fine, but try to login to an existing user or create a new one and I get the error described by Mukul above. Anyone run into this kind of an issue before?

# re: Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers

Thursday, August 31, 2006 10:35 PM by ScottGu

Hi Mark,

When a login fails, ASP.NET writes out an error message to the Windows Event Log (I believe under the application node).  Can you open this up to see what error message was generated.  This will help in debugging the issue.

Thanks,

Scott

# re: Always set the &quot;applicationName&quot; property when configuring ASP.NET 2.0 Membership and other Providers

Monday, September 04, 2006 5:15 AM by Mehdi
Hello there. I tried the above proposed solution but I'm still having problems. I'm sure my problem is very similar and has to do with this applicationName thing. On my developement machine I can debug my website add users etc, but as soon as I deploy the website on the Windows-2003 server all my membership and profile information is obsolete. Just as you described above the two websites (identical code and config) seem to point to different databases. I set my applicationName="/myAppX" on both providers (membership and profile) but it doesn't seem to work. Note that I have Visual Studio 2005 on both machines, my local PC and the server, so I can use the ide for debugging on both machines. When using the "ASP .NET configuration" button of the IDE to manage my users I DO notice that the applicationName is different. On my Machine it does point to "/myAppX" but on the server it points to "/" even though the config file specifies "/myAppX". I could sort of this problem on the server by puting the website on a CW2 directory and not localhost. In short, if I use the default localhost to "host" the website, then applicationName is always "/". I hope it's clear and that some one can help me.

# re: Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers

Tuesday, September 05, 2006 2:19 AM by ScottGu

Hi Mehdi,

If you want to send me your web.config file via email (scottgu@microsoft.com) I can help you figure out what is going on.

Thanks,

Scott

# re: Always set the &quot;applicationName&quot; property when configuring ASP.NET 2.0 Membership and other Providers

Tuesday, September 12, 2006 12:23 PM by Robert Woltz
OK, I have tried everything NOTHING works, it does create a new user and role for that user but there it quits. Create the new user to check it out if you would like, tried to log back in and that didn't help either same error can't find me. Changed the directory permissions etc. NOTHING seems to help this is flustrating. Spend 7.5 hours with MS yesterday with the reload the application to the server. In other words nothing they did worked. This has to be simple, I must be overlooking something really easy.

# re: Always set the &quot;applicationName&quot; property when configuring ASP.NET 2.0 Membership and other Providers

Wednesday, September 13, 2006 6:43 AM by Francis
Hi Scott, First, thank you for your invaluable work in communicating around and deep inside the .Net platform. As seen through the source code for the SqlMembershipPrivider, this is clear that the AspNet db may be used as a central point to authenticate users for many different applications, and manage roles for those coupled users/applications. Hence the ApplicationName property is very important. But as far as I can see, different User instances are created for those different applications. This should'nt be the case if we choose to transition to an ADMembershipProvider. A user in Active Directory seems to be defined outside any application scope. I understand that, putting apart Azman and ADAM stuff for roles and authorization management, groups in AD could be used to map roles. But then groups are not defined in any application scope... Does the ADMembershipProvider use the ApplicationName to, say ValidateUser, for exemple ? What sort of mapping could we apply in such a transition from a centralized / multi-application ASPNET db to an Active Directory ? Is the ADMembership / SQLRoles mix, via ProviderUserKey the simplest way to build an AD based central repository or transition from a SQL based one ?

# re: Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers

Friday, September 15, 2006 3:03 AM by ScottGu

Hi Francis,

Good questions.  I don't think that the ADMembershipProvider uses the ApplicationName property -- although I'm not 100% sure.  I would recommend still setting it, though, since it can't hurt.

This tutorial of mine covers how to use the SqlRolesProvider together with Windows Authentication (it could also be used with the ADMembershipProvider), and I think could help with what it sounds like you are looking for: http://weblogs.asp.net/scottgu/archive/2006/07/23/Recipe_3A00_-Implementing-Role-Based-Security-with-ASP.NET-using-Windows-Authenticat