Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Using Asp.Net Configuration Tool On Production Server

Posted on 2009-07-07
11
Medium Priority
?
409 Views
Last Modified: 2017-08-30
I am not able to execute this line of code on my web host....
 Roles.AddUserToRole(username, "User");

The reason is the "User" role has to be added in the Asp.Net configuration tool. How can I access the asp.net configuration tool on a proiduction server. I dont have physical access to the server I am using lunarpages as a webhost. Or is there a way to manually add a role(whatever the asp configuration tool is doing when you add roles). I have tried to simply add data to the aspnet_Roles table but it doesnt  work because I think someowhere the configuration tool is generating its own "roleid" or I need to do something else the aspnet configuration tool is doing behind the scenes. Thanks in advance
0
Comment
Question by:npl77
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 41

Expert Comment

by:guru_sami
ID: 24796497
Roles.AddUserToRole(username, "User");
should do the work...
Are you getting any errors? if so what?

AspNet Configuration will work on local machine only.
0
 

Author Comment

by:npl77
ID: 24796916
The exception I am getting on the live server is "Unable to connect to SQL Server Database". The thing is I am accessing the database in previous and subsequent lines of code no problem. So I tested this scenerio on my local machine. If I dont add roles in the conguration tool AddUserToRole breaks on the local machine even though there are roles with roleids in the aspnet_Roles table. So on my local machine I have a case where the config tool shows no roles and there are roles in the table this scenerio wont let AddRoleToUser work. Now if I add a role to the config tool then AddRoleToUser works fine. So this tells me aspnet configuration tool is doing something more than simply adding a role to the aspnet_Roles table.
0
 
LVL 41

Expert Comment

by:guru_sami
ID: 24796950
Looks the connectionString for your Role Provider is not pointing to right DB.
Can you share your membership and role provider settings from your web.config here.
0
Plesk WordPress Toolkit

Plesk's WordPress Toolkit allows server administrators, resellers and customers to manage their WordPress instances, enabling a variety of development workflows for WordPress admins of all skill levels, from beginners to pros.

See why 2/3 of Plesk servers use it.

 

Author Comment

by:npl77
ID: 24797111
I dont know if I have roleprovider settings this is what i got in web.config...
<membership>
			<providers>
				<remove name="AspNetSqlMembershipProvider"/>
				<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider,&#xA;System.Web,&#xA;Version=2.0.0.0, Culture=neutral,&#xA;PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ASPNETDBConnection" enablePasswordRetrieval="false" enablePasswordReset="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" passwordAttemptWindow="10" minRequiredPasswordLength="5" minRequiredNonalphanumericCharacters="0" passwordStrengthRegularExpression="" requiresQuestionAndAnswer="false"/>
			</providers>
		</membership>
	<roleManager enabled="true"/>

Open in new window

0
 

Author Comment

by:npl77
ID: 24797163
How do I setup role provider settings. Maybe this is my problem. But how can it be working on my local machine if I dont have the settings in my web config?
0
 
LVL 41

Accepted Solution

by:
guru_sami earned 2000 total points
ID: 24797165
You should modify your role provider like this.

Note the connectionString is ASPNETDBConnection where your roles are/to be stored.

<roleManager enabled="true">
<providers>
<clear />
<add name="AspNetSqlRoleProvider" connectionStringName="ASPNETDBConnection" applicationName="/" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</providers>
</roleManager>
0
 

Author Comment

by:npl77
ID: 24797222
Then just manually add the roles I want  to use to the aspnet_roles table?
0
 
LVL 41

Expert Comment

by:guru_sami
ID: 24797260
No if you add roles manually ..there is no guarantee that it will work...
You should add roles using Roles API i.e.
Roles.AddUserToRole(username, "User");
0
 

Author Closing Comment

by:npl77
ID: 31600705
Thanks again sami that fixed it! You have been a big help to me. Could you take a look a my ReportViewer problem doesnt seem like anyone can figure this one out.
0
 

Author Comment

by:npl77
ID: 24797360
What I meant by adding roles is adding the actual role like "User", "Administrator" etc...
0
 
LVL 41

Expert Comment

by:guru_sami
ID: 24798034
Not sure if you figured it out but...here is how you would create role
if(!Roles.RoleExists("User"))
        { Roles.CreateRole("User");
        }
For the ReportViewer problem...I don't have much exposure but let me see if have something to say on that.
0

Featured Post

Looking for a new Web Host?

Lunarpages' assortment of hosting products and solutions ensure a perfect fit for anyone looking to get their vision or products to market. Our award winning customer support and 30-day money back guarantee show the pride we take in being the industry's premier MSP.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question