Productive Edge | Microsoft at Productive Edge

CAT | MVC

Mar/12

22

Umbraco 5 Data Migration / Restore Issue

I recently migrated an Umbraco 5 site from a live environment to my local environment to make some changes, and ran into an issue. I backed up the database of the live site and restored it locally, updated the connection string located in the Hive config file to point to my local database (located at ~\App_Data\Umbraco\HiveConfig\web.config), and the site still would not load. I was presented with the following screen:

Umbraco 5
Install Umbraco 5.0.0 RTM
Welcome to Umbraco 5
It looks like Umbraco isn’t installed yet – click here to launch the install wizard.
Umbraco 5.0.0 RTM runs on ASP.NET MVC3. This is a standard MVC-powered page included as a demo of how your MVC application can serve pages alongside those managed by Umbraco CMS.
To learn more about ASP.NET MVC visit http://asp.net/mvc


After a few minutes of troubleshooting, I discovered that the issue was simply that the production environment was using a different user account for Umbraco to access the database than I was using locally, and even though I changed the connection string to reflect this, I forgot to associate the username with the database after the restore:

Umbraco SQL Server Login Properties

After checking the appropriate database roles for my user account everything was working again. Since Umbraco 5 doesn’t error or give any warning about why it is at the install screen, this wasted a little bit of my time. Hopefully this helps one of you troubleshoot a similar issue.

-Carson

· · · · ·

I have recently been working with Umbraco 5 (Jupiter), the newest version rebuilt from the ground up using ASP.NET MVC. One of the stranger issues that I ran into occurred after adding a Surface Controller, and a corresponding custom View to the pre-compiled site. The following error showed up after a build/save all:


The pre-application start initialization method Start on type System.Web.WebPages.Deployment.PreApplicationStartCode threw an exception with the following error message: Exception has been thrown by the target of an invocation.

Since I opened the site up as an ASP.NET MVC3 Web Site, adding the view added the following to the Web.config:

<add key="webpages:Enabled" value="true" />

Since it does this behind the scenes, I was confused about how the error started, and wasn’t able to catch it until doing a compare on a fresh Umbraco web.config, and the one that was in the project root. Hopefully this saves some of you some time

·

Feb/12

17

ASP.NET MVC CheckBoxFor explained

I have had a number of people ask about the CheckBoxFor method, and why it renders a hidden input tag with a value of false alongside the checkbox input. Here’s an example:

@Html.CheckBoxFor(m => m.IsEnabled)

will render

<input id="IsEnabled" type="checkbox" value="true" name="IsEnabled">
<input type="hidden" value="false" name="IsEnabled">

The reason this is done is because a form will not post anything to the server for an unchecked checkbox. In ASP.NET MVC, most of the time you are going to want a “false” value to be posted to the model binder, so the hidden value of false is there so that a value is posted back whether the checkbox is checked or not. If the checkbox is not checked, the form value for “IsEnabled” will be “false”, and if it is checked, both values will be posted as “true,false”. The model binder understands this, and will automatically take the true value from the collection of values. I have read that Ruby on Rails and MonoRail also use a similar technique.

No tags

Theme Design by devolux.nh2.me