The fluid transition you can now have between HTML and programmatic code, has made the all cshtml files a thing of beauty.
There are still some bits I am getting to grips with; the "Areas" functionality now provided for example.
In one case I am creating a mobile site, so creating a new area allows me to create a new _layout.cshtml file to reference a new css file and I found that you can reused any controllers from your parent MVC site, by adding the namespace to the namespaces array in the MapRoute object saving me a lot of work.
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"ms_default",
"ms/{controller}/{action}/{id}",
new {controller="Home", action = "Index", id = UrlParameter.Optional },
// this defines the namespace for the controllers I have already created in the parent site.
new string[] {"TMS.WEB.Controllers"}
);
}
Then I needed to add all the views from the parent site I wanted. I had to drop in the views even though they are the same for now, as it kept going off to use the layout and views defined in the parent site.
It would have been useful to only have to define as few files as necessary, but I guess I can just copy and replace the files as I maintain the site.
No comments:
Post a Comment