WebMatrix - Is it really this hard to publish?

Discussion in 'General troubleshooting' started by hoWIWeb, Nov 25, 2011.

  1. Hello,

    I am trying to get a really simple WebMatrix site published using the StarterSite with SQL CE database. I am getting all kinds of errors.

    First it published to a "myapps" folder not the root directory of the site so I fixed the publish profile. Then I turned on directory browsing. Then I got a localhost error so I added the line of code to the webconfig file. Then I got a an error about a role manager not being configured. Here is my current web.config

    If I am using SQL CE, why is the LocalSQLServer argument even needed?

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
    <system.data>
    <DbProviderFactories>
    <remove invariant="System.Data.SqlServerCe.4.0" />
    <add invariant="System.Data.SqlServerCe.4.0" name="Microsoft® SQL Server® Compact 4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
    </DbProviderFactories>
    </system.data>

    <connectionStrings>
    <remove name="LocalSqlServer" />
    <add name="LocalSqlServer" connectionString="Data Source=DBServerName;Integrated Security=false;Initial Catalog=DBName;User ID=DBLogin;Password=DBPassword" providerName="System.Data.SqlClient" />
    </connectionStrings>
    </configuration>
     
  2. This is what I got from DASP support and it seems to work. I'll see what happens when I republish? Hope this helps someone else trying to resolve...

    --- from DASP Support ---

    It appears that you are trying to publish an MVC/Razor application with Web Matrix. To resolve the 'LocalSqlServer' error, please perform the following steps:

    1) Log into your site using IIS7 Manager by following the instructions in this Knowledge Base article:

    http://support.discountasp.net/KB/a400/how-to-connect-to-windows-2008iis-7-using-microsoft.aspx

    2) Double click on the Connection Strings module.
    3) Double click on LocalSqlServer and copy the connection string to a text file/clipboard.
    4) Highlight LocalSqlServer and click on Remove which will add this entry into the web.config file:

    <remove name="LocalSqlServer" />

    5) Click on Add to re-add the 'LocalSqlServer' entry. For the Name, type 'LocalSqlServer', check custom, and copy the connection string you saved earlier.

    You may then run into a "Role Manager" Error. Here are the steps to resolve this error:

    1) Go back to Web Matrix and click on the ASP.NET Web Pages Administration link.
    2) Enter and create a password.
    3) Go back to Web Matrix and click on Files.
    4) Expand the App_Date -> Admin folder.
    5) You will need to remove the underscore (_) from the Password.config file.
    6) Go to Site and click on the ASP.NET Web Pages Administration link again.
    7) Enter the password.
    8) Change the Source drop down list to Default (All).
    9) In the Search field, type in "SimpleMembership" and click the Search button.
    10) Install the SimpleMembership.Mvc 1.2 package. (Or select the provider you would like to use for your application.)
    11) This will load the membership provider database into your application and reference any necessary .dlls.
    12) Republish the site.

    If WebMatrix overwrites your web.config for some reason, please re-apply the 'LocalSqlServer' fix above. These are the steps you need to take if you want to use ASPNET Membership and publish with Web Matrix.
     
  3. hey thanks for making this post, i was getting the same errors, and your solution worked.


    Before purchasing hosting on this site, i used their free hosting service, which did not have this issue.
     
  4. Apparently so

    Hey HoWIWeb,

    That's a lot of hoops to jump through. Unfortunately it did not work for me. Did you ever try to deploy membership on dasp hosting with SQL CE? My site didn't work, so I uploaded Microsoft's "Starter site" template since it is known good code. It doesn't work either, so I know it's not my code.
     
  5. I eventually caved in the wall with my forehead

    I have a site that will require simple Membership DB access for authenitication, and since I have almost no control over the the remote IIS administration, I opted to use SQL Server Compact. I simply created a new Web Application in Visual Studio 2010, for MVC with C#. I also got some pretty good advice on deployment from this article: Deployment to Hosting Provider. This is a multi-part tutorial on using SQL Server Compact, and deploying on a Hosting Provider.

    The part that frustrated me to no end was that every time I ran the application, I kept getting an error about 'path not found' to my .sdf db file. The provider built into the MVC app is SUPPOSED to create this database if it does not already exist. I chased my tail for two days looking for what was wrong with my web.config and the 'DataDirectory' variable used therein. What I eventually had to do was just copy over an old .sdf file into the directory structure's App_Data folder -- and the correct .sdf file was then created. The application then just worked, VOILA!

    The lesson learned: make sure the whole directory structure is in-place (including an App_Data folder), or the application will not be able to create (or use) your SQL Server Compact db.
     

Share This Page