ASP.NET MVC Gotcha in AccountControllerTest using october theme
I have downloaded ASP:NET MVC RC1 and begun to follow the Contact Manager tutorials.
I downloaded the October theme. As per the instructuons in this tutorial i copied the theme directories to my MVC-solution.
The theme worked ok but i got a lot of compilation errors in the AccountControllerTest.cs :
Error 17 The type or namespace name 'IMembershipService' could not be found (are you missing a using directive or an assembly reference?) C:\vsproj\mvc\ContactManager\ContactManager.Tests\Controllers\AccountControllerTest.cs 131 13 ContactManager.Tests
Error 18 The type or namespace name 'AccountMembershipService' could not be found (are you missing a using directive or an assembly reference?) C:\vsproj\mvc\ContactManager\ContactManager.Tests\Controllers\AccountControllerTest.cs 131 56 ContactManager.Tests ....etc
It turns out that the theme replaces the file AccountController.cs and the version included with the theme seems to be constructed in a different way than the RC1 version.
Solution/Workaround
The october-theme refrences the AccountController actions LogIn and Logout in whereas the RC1 actions are called LogOn and LogOff respectively.
This can be changed in the following files:
Replace the the AccountController.cs with the one that came with MVC RC1 and make the following modifications.
// Add this function
public ActionResult LoginPartial()
{
return View();
}
The above method gets called here : Views\Shared\Site.Master(48)
initLogin('<%= Url.Action("LoginPartial", "Account") %>','<%= Url.Action("Login", "Account") %>');
Make changes to LoginLinkHelper.cs
if (isAuthenticated)
{
sb.Append(helper.ActionLink("Logout", "LogOff", "Account"));
}
else
{
sb.Append(helper.ActionLink("Login", "LogOn", "Account"));
}
Make changes to \Views\Account\LoginPartial.aspx(6)
[sourcecode language='ASP']
<% using (Html.BeginForm(”LogOn”, “Account”)) { %>
[/sourcecode]
So far i havent noticed any different behaviour in the logon/logoff behaviour.
The best solution would of course be to make these changes to the files in the October theme itself so it will be vompatible with the RC1 and in the future the v 1.0 of MVC.