Thoughts from Dan Miser RSS 2.0
# Friday, February 04, 2011

My main hard drive died a couple of nights ago. Not the horrific, platters are creaking, smoke is coming out of if, quick and painless death. No, it was more the kind of death where it suddenly couldn't boot, but I could see the files on it still, kind of death.

After a few hours trying various things: Windows Startup Repair (hang on detecting Windows installs); run SeaTools to get diagnositcs on it (invalid op code when trying to boot to SeaTools for DOS; not all tests would run in SeaTools for Windows; upgrade to the latest versions from the Seagate website, and try again with the same degree of failure); and trying to do an image using SeaTools (hang with 16 minutes to go), I decided to just go out and buy a new hard drive and restore from Windows Home Server.

The restore process was painless. I followed the link in the WHS readme.txt, burned an ISO image to CD, booted from that CD, and the rest was about 3 mouse clicks and 2.5 hours to restore. The machine booted right up with everything right like I left it.

Next time I know: just start with Windows Home Server Restore first. WHS absolutely is amazing!! However, if you're interested in WHS, it really would be better for you to buy it sooner, rather than later. I don't understand why, but the link to that blog post shows that Microsoft is going to completely ruin WHS with the next version by getting rid of drive extender. When my WHS finally dies, I'll have to look around for a simple NAS solution, go to Drobo, or hope someone else comes along to fill the void that WHS is leaving with the Vail release. I don't think I've ever thought so highly of a product that I feel so strongly negative towards at the same time.

Friday, February 04, 2011 9:08:59 AM (Central Standard Time, UTC-06:00)  #    Comments [2] -

# Wednesday, February 02, 2011

First things first: .NET Reflector is, and always has been, an amazing piece of technology. Any .NET developer that has worked for any length of time has benefited from the original vision of Lutz Roeder. Secondly, I don't blame him in the least bit for selling to RedGate to profit on his effort and talent. He more than earned it.

But let me get this straight: According to the CEO of RedGate, they made a mistake buying it. There's no other way to put it. They hoped it would lead to increased sales of their overpriced tools, and it didn't. They hoped that it would lead users to purchase premium versions of Reflector, and it didn't. Gee, I'm sure no one could have possibly predicted that! (Yes, that was sarcasm). Only someone completely out of touch with developers would think "I know! I'll make inroads to the development community by just buying out a product that used to be free, and start charging for it". Let me know how that works out for you. You bought Reflector as a loss-leader and to buy your way in to the community. Live with the consequences of your incompetent decision.

The issue is not the $35. I've spent more for worse tools. But when I've done that, it's almost always been to support the effort of a one-man shop working his butt off. It is not going to happen in order to have some corporate entity try to recoup losses on a bad business decision. They knew all along that Reflector didn't align with the tools that they sell.

Taking away the free version simply shows that RedGate management is clueless. As for me, I'll put $100 towards the next free/open reflector to come along instead of rewarding RedGate with a sale.

Wednesday, February 02, 2011 5:09:12 PM (Central Standard Time, UTC-06:00)  #    Comments [3] -
.NET
# Tuesday, February 01, 2011

For an ASP.NET MVC application, consider the following code fragment, where GetDetails will return HTML markup:


<%using (Ajax.BeginForm("GetDetails", new AjaxOptions { UpdateTargetId = "result" })) { %>
  <input type="submit" />
<% } %>
<span id="result" />

This code works beautifully in Firefox and Chrome, but in IE (at least 7 and 8), it ends up chewing up parts of the master page, wreaking havoc on the layout of the rendered page. The problem is that the span tag is a void element (it only has a start tag). If you physically specify the span as a start and end tag, e.g. <span id="result"></span>, then the code will work fine in all 3 browsers.

I was tempted to blame IE, and I still sort of do, but at least they're handling the HTML spec properly. w3.org clearly specifies that the span tag is not allowed to be a void element (search within the page for "void element" to see the list of allowed void elements), and it's consistent on the span reference page. The reason I still sort of blame IE is:

  1. Mozilla and Chrome understand that a void span element can be expanded in to start and end tags
  2. A void span element works just fine if it's enclosed in another HTML element, e.g. <td><span id="result" /></td> will display the returned HTML just fine
  3. When looking at the rendered page with IE Developer Tools, if a void span element is encountered in a content page, they go back to the master page and stuff the rest of the master page in the span. I guess they're free to implement malformed HTML anyway they like, but this just seems crazy.

The takeaway: All of this due to a missing end tag for a span. Ugh!

Tuesday, February 01, 2011 8:49:29 PM (Central Standard Time, UTC-06:00)  #    Comments [0] -
ASP.NET | ASP.NET MVC
# Monday, January 17, 2011
As many of you know, biking has become an extremely big part of my life over the past few years. To make matters worse, I'm passing this passion for cycling on to my 14-year old daughter, Emily! The above picture was taken last September when we rode 65 strong miles in honor of our friend, Kerry Bacchi, who lost her fight with breast cancer shortly after that ride. I was extremely proud of how well Emily rode, through torrential downpours and cold, all the while never uttering one word of complaint. I thought it showed maturity beyond her years that she knew she was riding for a bigger cause.

That's why I'm joining Team in Training again this year. This marks the fourth time I'll be training for a 100 mile ride through the mountains of Lake Tahoe, but I need your help to do it! I need to raise a minimum of $3,900 for the Leukemia Society. By donating your money, you get a tax deductible donation, and also help an organization to provide support to patients and research a cure. I am extermely impressed with this organization, mainly because of how donated funds find their way to directly helping those in need.

Thanks for your time, and I look forward to your donation. Don't forget to ask if your employer has a matching gift program - that will really help maximize the impact of your donation. Remember, every little bit helps!

Click here to donate!

Monday, January 17, 2011 6:14:40 PM (Central Standard Time, UTC-06:00)  #    Comments [0] -

# Sunday, January 16, 2011
I'm running a web site with MSSQL 2008R2 Express as the backend. Unfortunately, that means there are some enterprise features missing. Most notably, a way to easily perform a scheduled, automated backup of the database. Along comes SQLBackupAndFTP to the rescue! It's free for very small usage, cheap for bigger installations, is easy to use, and has a slew of technical features (automate backups, email notification, zipped files, support for ftp, and a bunch more).

If you need something to automate your MSSQL Express databases, this tool is worth a few minutes of your time to check out.

Sunday, January 16, 2011 7:11:01 PM (Central Standard Time, UTC-06:00)  #    Comments [0] -

# Saturday, January 15, 2011
Rather than another "me too" post on the release of ASP.NET MVC 3, which Hanselman, Haack, and Guthrie have covered in-depth, I thought I'd post the good news that a couple of bugs that have bothered me are fixed in this version.

  1. There was a problem when using auto-detecting view engines when compiling under release mode. Basically, if you hit the site with your desktop browser first, and then come in with the mobile phone, you would still be presented the desktop version. This is now fixed.
  2. I posted about a problem with binding with the RC2 release. This also appears to be fixed.
Throw in the new scaffolding support, and 2011 is shaping up to be a great year for MVC.
Saturday, January 15, 2011 1:25:35 AM (Central Standard Time, UTC-06:00)  #    Comments [3] -
.NET | ASP.NET MVC
# Saturday, January 08, 2011
Here's a short one today, because I know I'll need this again in the future. If you have a MacBook Pro, and you're running Windows via Bootcamp, use this key combination to do a screen grab:
SHIFT + FN + F11

The Apple support article listing a bunch of key mappings can be found here.

Saturday, January 08, 2011 11:17:40 PM (Central Standard Time, UTC-06:00)  #    Comments [2] -
Macintosh
# Monday, January 03, 2011
I recently moved away from shared hosting, and went to a virtual private server in order to scale a site out better. Unfortunately, this meant that I needed to take on more administration of the server to do things that are done for me in a shared hosting environment. One feature that I have come to rely on is one click publishing from VS.NET 2010. In order to make this work, you need to have WebDeploy set up properly.

I found the steps from this page to be very helpful. Another good guide can be found here.

Be careful if you install Web Deploy via the Web Platform Installer. For some reason, when I did this, the Management Service Delegation feature was not installed. I ended up uninstalling and then installing straight from the official site, and the feature was available.

I initially had some settings wrong, and was getting back HTTP 401 and 550 errors. The log files didn't provide much help, but you can add tracing to help diagnose the cause of most issues.

Monday, January 03, 2011 10:12:24 AM (Central Standard Time, UTC-06:00)  #    Comments [0] -
.NET | ASP.NET MVC
# Sunday, December 12, 2010
I updated my web sites to ASP.NET MVC 3 RC2, and started receiving exceptions when model binding. If you want the short version, visit this forum post for the answer. While my errors weren't caused by the same issue that was originally reported in that thread, the fix does work. To sum up even further, just add this line of code in your Global.asax Application_Start method:

ModelMetadataProviders.Current = new DataAnnotationsModelMetadataProvider(); 

The longer story is that I have a pretty involved multi-step (think "wizard"), deep-level object graph built up over many pages, so I immediately feared that I was unknowingly exploiting some loophole that just got fixed for RC2. I built a test case, so in the interest of not having to build that test case up from scratch again, it looked like this:
Model


public class Foo
    {
        private List<Bar> _bars;
        private List<Baz> _bazs;

        public Foo()
        {
            _bars = new List<Bar>();
            _bazs = new List<Baz>();
        }

        public List<Bar> Bars
        {
            get { return _bars; }
            set { _bars = value; }
        }

        public List<Baz> Bazs
        {
            get { return _bazs; }
            set { _bazs = value; }
        }
    }

    public class Bar
    {
        public int Amount { get; set; }
    }

    public class Baz
    {
        public int Value { get; set; }
    }

Controller


        public ActionResult Index()
        {
            var foo = new Foo();
            foo.Bars.Add(new Bar { Amount = 4});
            foo.Bars.Add(new Bar { Amount = 23 });
            foo.Bars.Add(new Bar { Amount = 30 });
            foo.Bazs.Add(new Baz { Value = 100 });
            foo.Bazs.Add(new Baz { Value = 200 });
            TempData["foo"] = foo;
            return View(foo);
        }

        [HttpPost]
        public  ActionResult Index(IList<Bar> bars, IList<Baz> bazs)
        {
            Foo foo = (Foo) TempData["foo"];
            foo.Bars.Clear();
            foo.Bars.AddRange(bars);
            foo.Bazs.Clear();
            foo.Bazs.AddRange(bazs);
            TempData["foo"] = foo;
            return RedirectToAction("Summary");
        }

        public ActionResult Summary()
        {
            Foo foo = (Foo)TempData["foo"];
            return View(foo);
        }

View


<% using(Html.BeginForm()) { %>
<%
    int barid = 0;
    foreach (var item in Model.Bars){%>

<%= Html.Hidden("Bars.index", barid) %> Bar:<%= Html.TextBox("Bars[" + barid +"].Amount", item.Amount) %> <% barid++; }%> <% int bazid = 0; foreach (var item in Model.Bazs) {%> <br /> <%=Html.Hidden("Bazs.index", bazid)%> Baz: <%=Html.TextBox("Bazs[" + bazid + "].Value", item.Value)%> <% bazid++; }%> <p /> <input type="submit" value="Next" /> <% } %>

I would receive the following call stack when trying to submit the form:


The parameters dictionary contains an invalid entry for parameter 'bazs' for method 
'System.Web.Mvc.ActionResult Index(System.Collections.Generic.IList`1[MvcApplicationRC2.Models.Bar], System.Collections.Generic.IList`1[MvcApplicationRC2.Models.Baz])'
in 'MvcApplicationRC2.Controllers.HomeController'. The dictionary contains a value of type 'System.Collections.Generic.List`1[MvcApplicationRC2.Models.Bar]', 
but the parameter requires a value of type 'System.Collections.Generic.IList`1[MvcApplicationRC2.Models.Baz]'.
Parameter name: parameters
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and
where it originated in the code.

Exception Details: System.ArgumentException: The parameters dictionary contains an invalid entry for parameter 'bazs' for method 
'System.Web.Mvc.ActionResult Index(System.Collections.Generic.IList`1[MvcApplicationRC2.Models.Bar], System.Collections.Generic.IList`1[MvcApplicationRC2.Models.Baz])'
in 'MvcApplicationRC2.Controllers.HomeController'. The dictionary contains a value of type 'System.Collections.Generic.List`1[MvcApplicationRC2.Models.Bar]', 
but the parameter requires a value of type 'System.Collections.Generic.IList`1[MvcApplicationRC2.Models.Baz]'.
Parameter name: parameters

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be 
identified using the exception stack trace below.

Stack Trace:

[ArgumentException: The parameters dictionary contains an invalid entry for parameter 'bazs' for method 'System.Web.Mvc.ActionResult
Index(System.Collections.Generic.IList`1[MvcApplicationRC2.Models.Bar], System.Collections.Generic.IList`1[MvcApplicationRC2.Models.Baz])' in
'MvcApplicationRC2.Controllers.HomeController'. The dictionary contains a value of type 'System.Collections.Generic.List`1[MvcApplicationRC2.Models.Bar]', 
but the parameter requires a value of type 'System.Collections.Generic.IList`1[MvcApplicationRC2.Models.Baz]'.

Parameter name: parameters]
   System.Web.Mvc.ActionDescriptor.ExtractParameterFromDictionary(ParameterInfo parameterInfo, IDictionary`2 parameters, MethodInfo methodInfo) +484514
   System.Web.Mvc.<>c__DisplayClass1.<Execute>b__0(ParameterInfo parameterInfo) +18

   System.Linq.WhereSelectArrayIterator`2.MoveNext() +85
   System.Linq.Buffer`1..ctor(IEnumerable`1 source) +325
   System.Linq.Enumerable.ToArray(IEnumerable`1 source) +78
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +133

   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
   System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +55

   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +263
   System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +19

   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +191
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343

   System.Web.Mvc.Controller.ExecuteCore() +116
   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97
   System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10

   System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
   System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12

   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
   System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50
   System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7

   System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9

   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8841105
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184
Sunday, December 12, 2010 8:29:59 PM (Central Standard Time, UTC-06:00)  #    Comments [2] -
.NET | ASP.NET MVC
Navigation
Archive
<February 2011>
SunMonTueWedThuFriSat
303112345
6789101112
13141516171819
20212223242526
272812345
6789101112
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2013
Dan Miser
Sign In
Statistics
Total Posts: 391
This Year: 2
This Month: 2
This Week: 0
Comments: 674
Themes
Pick a theme:
All Content © 2013, Dan Miser
DasBlog theme 'Business' created by Christoph De Baene (delarou)