Saturday, September 24, 2016

When NuGet puts stuff into my Web.config for a library, what is it up to?

The ConfigurationSection class in/at System.Configuration.ConfigurationSection allows configurations to be handed into your .dll from the Web.config of another project. Make your own class which inherits from ConfigurationSection. Let's say it's called InData. Then...

<section name="foo" type="MyApp.MyFolder.InData" />


...goes in configSections in the Web.config and this goes outside configSections...

<foo bar="baz" />


InData itself looks like...

public class InData : ConfigurationSection
   [ConfigurationProperty("bar", DefaultValue="qux", IsRequired=false)]
   public string Bar
      get { return (String)this["bar"]; }
      set { this["bar"] = value; }

get your exceptions in your MVC actions to end up as yet another validation fail at @Html.ValidationSummary() in your views

catch (Exception ex)
   ModelState.AddModelError("Exception", ex.Message);
   return View(whatever);

Could not copy "C:\Whatever\LibSassHost.Native\msvcp120.dll" to "bin\LisSassHost.Native\msvcp120.dll". Exceeded retry count 10. Failed.

When I got this error upon attempting to compile in Visual Studio 2015, I learned to deal with it by turning IIS off when compiling. If there is a way to change the .dll from "Copy Always" to "Copy Newer" that helps in situations like this.

I don't see why one can't put a title tag right by the H1 tag in a page.

Who says it has to go in the head tag? One may have link tags for stylesheets and JavaScript script tags partway down the body after all. I guess title-outta-head (fish-outta-water) may not work in IE9. In views in ASP.NET MVC apps we do some contortions to reach up the "MasterPage" view to doctor stuff up there on a "page by page" basis for customizations, but... do we have to?

Fixed widths may not play nicely with copy that changes when a new resource is used for a different language.

I'm not sure what to do about that. :(

You may import one Sass file into another much like importing one .css file into another.

@import 'whatever.scss';

This will allow you to make one file with common variable settings for others.

You must compare INT type T-SQL variables to a zero default instead of doing the ISNULL thing with them.