Hi, I use VWD 2005. When I posttheprogramto the hosting site, "ROLE" function doesn't work. When I log in, username and password are working fine. But it doesn't bring ROLE. If I test it at my local computer with connection to the discountasp.net hosting site's MS SQL 2005 database, it's working fine. My steps. 1. In VWD 2005 2. Build > Publish Web Site 3. I use Discountasp.net's hosting site. So after I Publish Web Site to this hosting site, I do data file attachement step as Discountasp.net instructed. 4. Then username and password are working fine. But "ROLE" doesn't come there. It is working fine at my local computer. Any advices? Thanks, Post Edited (Infokare) : 11/10/2007 8:30:44 PM GMT
Can you try elaborating a little more further? Are you saying when you log into your application you are getting a error message? Did you go to your ASP.Net Website Administration Tool and make sure that you have enabled Roles on your application before you uploaded it to our server? rcp DiscountASP.NET www.DiscountASP.NET
Hi, I am testing with sample program from Wrox Book, ASP.NET 2.0 instantresults, Chapter 6:Wrox Blog. You can download it from follwoing link. http://www.wrox.com/WileyCDA/WroxTitle/productCd-0471749516,descCd-download_code.html 1. I am using Visual Studio 2005. 2. Iopend it(Folder:Modifications) 3. Changed Web.config files': <connectionStrings> <add name="SqlServerConnectionString" connectionString="Data Source=tcp:sql2k511.discountasp.net;Initial Catalog=SQL2005_420732_tbh;User ID=username;Password=mypassword" providerName="System.Data.SqlClient" /> <!-- <add name="SqlServerConnectionString" connectionString="server=(local)\SqlExpress;AttachDbFileName=|DataDirectory|Blog.mdf;Integrated Security=true;User Instance=true" providerName="System.Data.SqlClient" /> <add name="AccessConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\Blog-Modified\App_Data\Blog.mdb;User Id=admin;Password=;" providerName="System.Data.OleDb" /> --> </connectionStrings> 4. In VS 2005, Build>Publish Website>(to my site) 5. Attached database file to MS SQL 2005 (Blog.mdf) 6. Open ASP.NET Configuration tool: make sure user names and roles in dasp' my hosting site 7A. Run it in VS 2005 : username and password function working fine. 7B. Run it in www.mysite.com(hosted in dasp.net) : username working fine, but "ROLE" doesn't. in this sample program ROLE "Administrator" is used in follwing 4 procedures. Your kind help would be really appreciated. Thanks, 1. Public Shared Function GetBlogEntry(ByVal blogEntryId As Integer) As BlogEntry If HttpContext.Current.User.IsInRole("Administrator") Then Return BlogManagerDB.GetBlogEntry(blogEntryId) Else Throw New NotSupportedException("Calling GetBlogEntry is not allowed when " & _ "you're not a member of the Administrator group.") End If End Function 2. Public Shared Sub SaveBlogEntry(ByVal myBlogEntry As BlogEntry) If HttpContext.Current.User.IsInRole("Administrator") Then BlogManagerDB.SaveBlogEntry(myBlogEntry) Else Throw New NotSupportedException("Calling SaveBlogEntry is not allowed when " & _ "you're not a member of the Administrator group.") End If End Sub 3. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then LoadData() End If If Context.User.IsInRole("Administrator") Then btnCreateNewBlogEntry.Visible = True End If End Sub 4. Protected ReadOnly Property CanEdit() As Boolean Get Return Context.User.IsInRole("Administrator") End Get End Property
Do you have this line inputted in your applications web.config file? ... <roleManager enabled='true' defaultProvider='CustomizedRoleProvider'> rcp DiscountASP.NET www.DiscountASP.NET
Hi, I changed it from Original Code of sample to per your advice. But it's still same-"ROLE" function does not bring. Thanks again, 1.Original Codes from sample: <roleManager enabled="true" cacheRolesInCookie="true" cookieName=".ASPROLES" defaultProvider="SqlProvider"> <providers> <add connectionStringName="SqlServerConnectionString" name="SqlProvider" type="System.Web.Security.SqlRoleProvider" /> </providers> </roleManager> 2. So I changed it as follows: <roleManager enabled="true" cacheRolesInCookie="true" cookieName=".ASPROLES" defaultProvider="CustomizedRoleProvider"> <providers> <add connectionStringName="SqlServerConnectionString" name="CustomizedRoleProvider" type="System.Web.Security.SqlRoleProvider" /> </providers> </roleManager>
Did you use your ASP.Net Configuration Tool within your VS 2005 to also set the roles on your db? You may want to run that again. rcp DiscountASP.NET www.DiscountASP.NET
Yes. I use VS 2005 tool. My steps are: 1. Test program locally 2. Change web.config file <connectionStrings> <add name="SqlServerConnectionString" connectionString="Data Source=tcp:sql2k511.discountasp.net;Initial Catalog=sql2005;User ID=SQL2005username;Password=my password" providerName="System.Data.SqlClient" /> <!--<add name="SqlServerConnectionString" connectionString="server=(local)\SqlExpress;AttachDbFileName=|DataDirectory|Blog.mdf;Integrated Security=true;User Instance=true" providerName="System.Data.SqlClient" />--> </connectionStrings> 3.In VS 2005: Build>Publish Website 4. AttachMDF file like this: My .mdf file(It's Blog.mdf)is already uploaded in App_Data folder when I Publish Website. So I do Attach Data File step in DASP Control Panel>MS SQL 2005> Attach Data File Use this tool to attach a data file (MDF) to your SQL 2005 database. 1. Upload the MDF file to your website account. 2. Enter the path of the MDF file relative to your website root: <input id=ctl00_cMain_txtMdfPath maxLength=254 size=30 value=\App_Data\Blog.mdf name=ctl00$cMain$txtMdfPath> Examples: \database.mdf \App_Data\aspnetdb.mdf WARNING: The current SQL 2005 database will be overwritten. 5. Using Web Site Administration Tool, I set(add) user name and role. ==>Here is some clue I hope. If I check user/role from different program but exactly same connectionstring to DASP hosting site, usernames are same, role does'nt bringthrough new(with different program)Web Site Administration Tool. It looks ROLE does not bring to hosting site, it resides somewher my local computer. This is same as my problem status-USERNAME bring there at hosting site but ROLE doesn't. Thanks,
Each Role in the membership database schema is associated with an Application (See aspnet_Roles table in your membership database,you see a ApplicationId in there) . Since you are trying to access roles from another application,it will not show up as part of that application. Vikram DiscountASP.NET www.DiscountASP.NET
Thanks a lot everyone. Finally I have reached the right answer. My problem wassample programauthor's advice "Also, make sure all application configuration sections have applicationName set to the same value, like /. " I added it to the roleManager like follows. Thanks again for your kind help. HD <roleManager enabled="true" cacheRolesInCookie="true" cookieName="TPHROLES" defaultProvider="TPH_RoleProvider"> <providers> <add connectionStringName="SqlServerConnectionString" applicationName="/" name="TPH_RoleProvider" type="System.Web.Security.SqlRoleProvider" /></providers> </roleManager>