1.4.5 Sql Server Switch From XML

Apr 23, 2009 at 6:41 PM
I had run the site before installing and converting to Sql Server Express on local machine. I have installed SqlServer and the BlogEngine tables, established security logins, ODBC connection tests ok and the site comes up after DBconn is successful but when I try to login, the site keeps using the XML files for validateUser. What do I need to change to have the site use the database instead?
Thank you,
Mike
Apr 24, 2009 at 6:09 PM
I've made all of the changes from AL's memberships/roles video and when I try to run the site in VS debugger, I get the following message as well the same message for every tag name through the remainder of the Web.config file:  "Could not find schema information for the element 'BlogEngine'. 

Any help on this would be appreciated. 

Coordinator
Apr 24, 2009 at 8:39 PM
What does your web.config file look like?  If you paste it here (minus any usernames/passwords), maybe we'll find a problem with it.
Apr 24, 2009 at 9:39 PM
Edited Apr 24, 2009 at 9:43 PM
Obvious newbie question...
Before I post the web.config, I noticed that I only get the errors when I open the Web site in VS 2008. If I just start VS and go right to debug, the site comes up and I can get to the login page. I only have the source running in the projects dir in VS and I don't have the site in the wwwroot. What am I doing wrong that causes this? BTW, ASP.net admin tool tests with successful connect for the admin user I set up but the login fails as invalid user when I try to login with it.
Thanks in advance for your patience... 
Coordinator
Apr 24, 2009 at 10:08 PM
I'm not entirely clear on which scenario you get errors in, and in which scenario you don't get errors in.

In VS 2008, you can open up the Web Site and hit F5, and it works?  If so, are you using the built-in Cassini web server where the URL contains a port number like http://localhost:3321/BlogEngine.Net... ?

In which scenario do you get errors in?  If you're using IIS where the URL doesn't contain a port number, then you'll want to make sure the folder BE is in is marked as an application in IIS.  This short tutorial shows some screenshots of creating an 'application starting point' which is the process of marking a folder an an application in IIS.
Apr 27, 2009 at 4:23 PM
Edited Apr 27, 2009 at 4:26 PM
Hi Ben, I'll try to provide some more info...being a newbie, I'm not sure if it helps much but maybe we can start here.

In VS 2008, you can open up the Web Site and hit F5, and it works?  If so, are you using the built-in Cassini web server where the URL contains a port number like http://localhost:3321/BlogEngine.Net... ?
When I run in VS, the login screen opens in I.E. with the URL: http://localhost:2164/BlogEngine.Web/login.aspx but I can't login using the Admin user and when I query the be_Users table, I see that the Admin user's row is there. 

In which scenario do you get errors in?  If you're using IIS where the URL doesn't contain a port number, then you'll want to make sure the folder BE is in is marked as an application in IIS.  This short tutorial shows some screenshots of creating an 'application starting point' which is the process of marking a folder an application in IIS.
In VS, if I do: File->Open->Website    then pres F5, I get the following in the Error List:
It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level.  This error can be caused by a virtual directory not being configured as an application in IIS. 
C:\Documents and Settings\JoeUser\My Documents\Visual Studio 2008\Projects\BlogEngine.NET 1.4.5\BlogEngine.Web\Web.Config 16

Info that may or may not be relavent:
  • I have the two 'administrators' and 'editors' roles defined with one user 'rdUser' in role 'administrator' in the ASP.net Web  Site Administration Tool. The provider 'AspNetSqlProvider' tests with result: 'Successfully established a connection to the database.' yet I see no rows in the aspnet_* Users or Roles tables.
  • After I initially did File->Open->Website    I noticed under my projects dir in VS there was an addition folder 'BlogEngine.NET 1.4.5 (2)' that only contained a VS solution file.

Since I wanted to learn from the BlogEngine source by developing some documented theme changes, etc. within VS 2008 IDE, I didn't think I needed to put the BlogEngine.Web folder into the wwwroot dir or define into IIS. Could this be the cause of my woes? If so, do I define into IIS from VS projects dir and follow the instructions on the short_tutorial link you provide?
Mike

    
 

Coordinator
Apr 27, 2009 at 8:07 PM
For the logging in problem, what are your default Membership and Roles providers in your web.config file?  There's 3 possibilities.  One possibility is shown below.

<membership defaultProvider="DbMembershipProvider">
... and ...
<roleManager defaultProvider="DbRoleProvider" enabled="true" cacheRolesInCookie="true" cookieName=".BLOGENGINEROLES">

If you're using DbMembershipProvider and DbRoleProvider (as shown above), then BE is looking at the be_Users and be_Roles tables to authenticate you.

The "aspnet_" tables are used if you're using the "MSSQLRoleProvider" and "MSSQLRoleProvider" providers, as documented here.

If you're using the XmlMembershipProvider and XmlRoleProvider providers, then BE is using the users.xml and roles.xml files in the App_Data directory.

The default password is "admin", so you can try logging in using "admin" for the username and "admin" for the password.  If that doesn't work, then in the database, clear out the password so it's a blank password.  If its empty, the password of "admin" should work.

My preferred method of running BE on my local machine is to use IIS and configure VS2008 to launch the website using IIS.  You can still debug the website with this configuration.  If you mark the blog folder as an application in IIS (using that tutorial), then in VS2008, do File -> Open -> Website, and point to the folder where the blog is installed (the same folder you marked as an app in IIS).  This will open up the website in VS2008.  In the Solution Explorer, if you right-click on the blog folder (which is the very top or next to top node in Solution Explorer), and select Property Pages, a dialog window opens up with 5 choices on the left side (References, Build, Accessibility, Start Options and MSBuild Options).  If you select "Start Options", then on the right-side, select the "Use custom server" radio button.  For the "Base URL", enter http://localhost/blog or whatever the name of the folder marked as an application is in IIS.

After doing that, whenever you do F5 in VS, it will launch the blog in your browser using IIS -- so there won't be a port number in the URL.
Apr 28, 2009 at 9:33 PM
Edited Apr 28, 2009 at 9:46 PM
Ok, I'll do some studying on the links you provided. Should I use the values 

SqlMembershipProvider and SqlRoleProvider  as in Al's videos or MSSQLMembershipProvider MSSQLRoleProvider for BE 1.4.5?

Thanks, Mike 

 

 

 

 

 

 

Coordinator
Apr 28, 2009 at 9:45 PM
SqlMembershipProvider / SqlRoleProvider is the same as MSSQLMembershipProvider / MSSQLRoleProvider.  In this documentation, the providers are given names of MSSQLMembershipProvider and MSSQLRoleProvider.  You can see they map to System.Web.Security.SqlMembershipProvider and System.Web.Security.SqlRoleProvider.  These providers use the aspnet* tables.

The DB membership/role providers that BE offers are the DbMembershipProvider and DbRoleProvider.

Unless you have a reason for using SqlMembershipProvider and SqlRoleProvider, I would stick with DbMembershipProvider and DbRoleProvider which use the be_Users and be_Roles tables.  There is no correct value, however.  You can use the ones built into ASP.NET (SqlMembershipProvider/SqlRoleProvider), or the ones BE provides (DbMembershipProvider/DbRoleProvider) or the XML versions that BE also provides (XmlMembershipProvider/XmlRoleProvider).  You just need to make sure the DB tables are setup for the providers you choose, and be aware of which tables data is coming into and out of.