How to use a dynamic front page in ASP.NET MVC RC 1.0

I do not know how to use the dynamic main page in ASP.NET MVC RC 1.0. Please, help!

+1
source share
3 answers

You can specify the name of the main page when using the helper method View ():

return View("About", "AlternateMaster", model);

AlternateMaster will solve ~ / Views / Shared / AlternateMaster.master

Found here

+8
source

I got this to work by creating a base controller that handled the OnActionExecuted event. In OnActionExecutedevent, I assign the main page. Then I made all my other controllers inherited from the base class.

public class BaseController : Controller
{
     protected override void OnActionExecuted(ActionExecutedContext filterContext) {
         var action = filterContext.Result as ViewResult;
         if (action != null) {
             action.MasterName = MyApp.Properties.Settings.Default.Theme;
         }  

         base.OnActionExecuted(filterContext);
     }
}

,

+3

Source: https://habr.com/ru/post/1748713/


All Articles