I am trying load a View(MVC not angular) into a custom section and could use some help. It works if I use "return Content()", but nothing happens with I use "return View()". The form is empty.
The forms in the view will be interacting with an external SQL Server database via an api. There is no need for a Tree with this section, so one is not being implemented. What am I doing wrong?
I was able to get it working. Not sure if there is a better way or not, but I found a Umbraco JavaScript function [UmbClientMgr.content (url)] that provided a way to get it to work. The only issue I am having now is that the function causes the "spinner" to show and I have not figured out how to get rid of it. If you know how to remove it, please let me know.
THE SHORT VERSION of getting it to work is to use the page in your Dashboard.config file as a relay to load your MVC page.
using umbraco.businesslogic;
using umbraco.interfaces;
namespace YourProject.AppPlugins.AgentAdmin .Umbraco.EditorTools.AppPlugins.EditorTools
{
[Application("agentProfiles", "Agent Profiles", "icon-name-badge", 10)]
public class AgentProfiles : IApplication
{ }
}
AgentAdminTree.cs
using System;
using System.Collections.Generic;
using umbraco.businesslogic;
using umbraco.BusinessLogic.Actions;
using umbraco.cms.presentation.Trees;
using umbraco.interfaces;
//Stubbing if needed later
namespace YourProject.App_Plugins.AgentAdmin
{
//[Tree("AgentAdmin", "Agent Admin", "TBD")]
//public class EditorToolsTree : BaseTree
//{
// public EditorToolsTree(string application)
// : base(application)
// {
// }
Getting View to Load in backend
Hi,
I am trying load a View(MVC not angular) into a custom section and could use some help. It works if I use "return Content()", but nothing happens with I use "return View()". The form is empty.
The forms in the view will be interacting with an external SQL Server database via an api. There is no need for a Tree with this section, so one is not being implemented. What am I doing wrong?
I am using this as my guide: http://www.jondjones.com/learn-umbraco-cms/umbraco-developers-guide/customising-umbraco-ui/how-to-display-an-mvc-view-in-the-umbraco-backend
Controller
}
AgentProfile.cshtml
Hello, It Works! @Model.FirstName @Model.LastName
Hi Graham
It's not working with View(), because View() is trying to return view, and you need plain html to return
Thanks,
Alex
You can render view in the controller and return a plain html with this method:
I was able to get it working. Not sure if there is a better way or not, but I found a Umbraco JavaScript function [UmbClientMgr.content (url)] that provided a way to get it to work. The only issue I am having now is that the function causes the "spinner" to show and I have not figured out how to get rid of it. If you know how to remove it, please let me know.
THE SHORT VERSION of getting it to work is to use the page in your Dashboard.config file as a relay to load your MVC page.
Then in LaodDefault.html,
THE LONG VERSION is posted below. I would have preferred to post this in a zip, but that is not an available option.
RouteConfig.cs
using System.Web.Mvc; using System.Web.Routing;
namespace YourProject.AppPlugins.AgentAdmin.AppStart { public class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); RouteTable.Routes.MapRoute( "AgentAdmin", "umbraco/backoffice/Plugins/AgentAdmin/{action}/{id}", new { controller = "AgentAdmin", action = "AgentProfile", id = UrlParameter.Optional }); } } }
WebApiConfig.cs
using System.Web.Http;
namespace YourProject.AppPlugins.AgentAdmin.AppStart { public static class WebApiConfig { public static void Register(HttpConfiguration config) { config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); } } }
AgentProfileController.cs
using System; using System.Web.Mvc; using Umbraco.Web.Mvc;
namespace YourProject.App_Plugins.AgentAdmin.Controllers { public class AgentAdminController : UmbracoAuthorizedController { public ActionResult AgentProfile() { try { Agent agent = new Agent(); agent.FirstName = "Mickey"; agent.LastName = "Mouse";
}
AgentProfile.cshtml
@model Agent
Hello @Model.FirstName @Model.LastName
LoadDefault.html
Web.config
AgentAdminSection.cs
using umbraco.businesslogic; using umbraco.interfaces;
namespace YourProject.AppPlugins.AgentAdmin .Umbraco.EditorTools.AppPlugins.EditorTools { [Application("agentProfiles", "Agent Profiles", "icon-name-badge", 10)] public class AgentProfiles : IApplication { } }
AgentAdminTree.cs
using System; using System.Collections.Generic; using umbraco.businesslogic; using umbraco.BusinessLogic.Actions; using umbraco.cms.presentation.Trees; using umbraco.interfaces;
//Stubbing if needed later namespace YourProject.App_Plugins.AgentAdmin { //[Tree("AgentAdmin", "Agent Admin", "TBD")] //public class EditorToolsTree : BaseTree //{ // public EditorToolsTree(string application) // : base(application) // { // }
}
StartUpHandler.cs
using System.Web.Routing;
using Umbraco.Core;
namespace YourProject.AppPlugins.AgentAdmin.AppStart {
public class StartUpHandlers : ApplicationEventHandler {
}
is working on a reply...