Monday, October 31, 2016

Guide to using Strong Typed PublishedContnetModels in Umbraco 7

The recent Umbraco 7.4 release there is an included Model Builder tool.  This may not seem like a big deal but it can be very helpful to developers and I recommend embracing it.  In essence what it does it let you generate strong typed models in .Net based off your Document Types and Media Types and their hierarchy.  This can be done a few ways including at runtime in memory or with pre-compile DLL’s.  Then in Views, Macro’s and Controllers these strong typed models can be used instead of normal code to reduce potential coding errors and typos, and to provide IntelliSense in Visual Studio if you do editing there.  These changes for the most part are non-breaking and the old style can still be used.

In short if will replace the first example template with the second.
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@Model.Content.GetPropertyValue(“myProperty”, true, “Missing”)
@Umbraco.Field("myProperty ", recursive: true, altFieldAlias: "defaultProperty")

@inherits Umbraco.Web.Mvc.UmbracoTemplatePage<DocumentType>
@Model.Content.GetPropertyValue(s => s.MyProperty, true, “Missing”)
@Model.Content.GetPropertyValue(s => s.MyProperty, true, Model.Content.DefaultProperty)

This article describes the following approach:  Generating C# models in the live Umbraco Instance and then pulling them down into the generated models down into the source Visual Studio Project and pre-compiles them there in the main application DLL.  This has some major benefits over other approaches including:
  • All code is pre-compiled and no generation or compilation is happening when the website is actually running or starting up.
  • Models generation isn’t dependent on IIS Express and you don’t have to do desin work there or start up slow projects to manually create models.
  • Models are generated the same place you edit the document types and generated automatically.
  • Models are partial class’s that can be extended and can implement custom interfaces as needed.
  • There is no need for any special visual studio plugins or deployment rules to make this work.  All parts described will work on any Visual Studio Editions.

Wednesday, October 26, 2016

Removing Double Redirects or Redirect Chains form .htaccess files.

If you manage and large site using mod_rewrite or ISAPI_Rewrite 3 you will eventually run into issues maintaining the rewrite rules. After doing a few redesigns or moving things around repeatedly you can end up with situations where one page redirects to another page then another and so on in a chain. This is functional but inefficient, it can have a negative effect on user experience and on SEO value, and makes everything harder to maintain. This tool is a simple script you can pass you .htaccess file through to remove all these multi-step redirects and all pages redirect immediately on the first redirect to the final destination page.

Tuesday, October 25, 2016

Steam won't connect on mass Sierra 10.12

I was running into this odd issue after upgrading to OS X 10.12 and nothing I would do seamed to resolve it.  Tired tracking down error messages, reinstalling steam, changeling to beta and back, and other fixes.  Ended up doing the following fix which straightened everything out.