Forked from mattbrailsford/ListingController.cs
Last active
December 20, 2015 12:59
-
-
Save sniffdk/6135323 to your computer and use it in GitHub Desktop.
A slightly modified version of custom controllers/views. Works perfectly on my machine :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Global : UmbracoApplication | |
{ | |
protected override void OnApplicationStarting(object sender, EventArgs e) | |
{ | |
base.OnApplicationStarting(sender, e); | |
DefaultRenderMvcControllerResolver.Current.SetDefaultControllerType(typeof(ListingPageController)); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@inherits UmbracoViewPage<Starterkit.Controllers.ListingViewModel> | |
Current listing: @Model.CurrentListing.Name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ListingPageController : RenderMvcController | |
{ | |
public override ActionResult Index(RenderModel model) | |
{ | |
return CurrentTemplate(new ListingViewModel | |
{ | |
CurrentListing = new Listing {Name = model.Content.Name} | |
}); | |
} | |
} | |
public class ListingViewModel | |
{ | |
public Listing CurrentListing { get; set; } | |
} | |
public class Listing | |
{ | |
public string Name { get; set; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment