I have been playing around with Umbraco 7 for the past 2 months now and I am struggling to get the MVC 5 Template Pages to work correctly. The Template comes with Account and Manage Controllers with builtin Login/Register etc. functionality. I am using Macros for each of the pages that renders views and converted the controllers to be Surface Controllers.
I got the Login and Register parts working with lots of frustration and now I am moving on to the Manage side of the app. I can load my Manage/Index page but when I try and load the ManageLogins page the macro fails to load.
I think it has something to do with the fact that most of the Action Results are asynchronous but it doesn't make sense why the Manage/Index page loads as it's exactly the same as the ManageLogins action result.
I have made sure that I return PartialViews for all the actions that returns views and also the models that goes with the pages.
So here is the code for my Controller and Action:
//
// GET: /Manage/Index
public async Task<ActionResult> Index(ManageMessageId? message)
{
ViewBag.StatusMessage =
message == ManageMessageId.ChangePasswordSuccess ? "Your password has been changed."
: message == ManageMessageId.SetPasswordSuccess ? "Your password has been set."
: message == ManageMessageId.SetTwoFactorSuccess ? "Your two-factor authentication provider has been set."
: message == ManageMessageId.Error ? "An error has occurred."
: message == ManageMessageId.AddPhoneSuccess ? "Your phone number was added."
: message == ManageMessageId.RemovePhoneSuccess ? "Your phone number was removed."
: "";
var userId = User.Identity.GetUserId();
var model = new IndexViewModel
{
HasPassword = HasPassword(),
PhoneNumber = await UserManager.GetPhoneNumberAsync(userId),
TwoFactor = await UserManager.GetTwoFactorEnabledAsync(userId),
Logins = await UserManager.GetLoginsAsync(userId),
BrowserRemembered = await AuthenticationManager.TwoFactorBrowserRememberedAsync(userId)
};
return PartialView(model);
}
The controller inherits from SurfaceController
ManageController : SurfaceController
My Model:
public class IndexViewModel : BaseUmbracoModel
{
public bool HasPassword { get; set; }
public IList<UserLoginInfo> Logins { get; set; }
public string PhoneNumber { get; set; }
public bool TwoFactor { get; set; }
public bool BrowserRemembered { get; set; }
}
BaseUmbracoModel:
public class BaseUmbracoModel : RenderModel
{
public BaseUmbracoModel() : base(UmbracoContext.Current.PublishedContentRequest.PublishedContent, UmbracoContext.Current.PublishedContentRequest.Culture) { }
}
Now all of that works but when I try and navigate from the Manage/Index page to the ManageLogins page then I get this error:
An exception of type 'System.Web.HttpException' occurred in System.Web.dll but was not handled in user code
Additional information: Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'.
Now I don't understand why the Manage/Index page is working but the ManageLogins page is not working.
Has anyone got the standard pages of an MVC 5 app to work correctly? Is there anything I am doing wrong?
I even followed this post for a possible solution but still nothing.
Getting MVC 5 Template working with Umbraco 7.4.3
Hi All
I have been playing around with Umbraco 7 for the past 2 months now and I am struggling to get the MVC 5 Template Pages to work correctly. The Template comes with Account and Manage Controllers with builtin Login/Register etc. functionality. I am using Macros for each of the pages that renders views and converted the controllers to be Surface Controllers.
I got the Login and Register parts working with lots of frustration and now I am moving on to the Manage side of the app. I can load my Manage/Index page but when I try and load the ManageLogins page the macro fails to load.
I think it has something to do with the fact that most of the Action Results are asynchronous but it doesn't make sense why the Manage/Index page loads as it's exactly the same as the ManageLogins action result.
I have made sure that I return PartialViews for all the actions that returns views and also the models that goes with the pages.
So here is the code for my Controller and Action:
The controller inherits from SurfaceController
ManageController : SurfaceController
My Model:
BaseUmbracoModel:
And then my View:
And lastly the macro that loads the Manage/Index page:
Now all of that works but when I try and navigate from the Manage/Index page to the ManageLogins page then I get this error:
Now I don't understand why the Manage/Index page is working but the ManageLogins page is not working.
Has anyone got the standard pages of an MVC 5 app to work correctly? Is there anything I am doing wrong?
I even followed this post for a possible solution but still nothing.
Regards Tiaan
is working on a reply...