Posts
1127
Comments
885
Trackbacks
1
Thursday, August 25, 2016
About Stereotypes: Compare and Contrast

Compare this point of view, with this point of view.

There are deep lessons in there.

posted @ Thursday, August 25, 2016 9:52 AM | Feedback (0)
Wednesday, August 24, 2016
Stress Management for Snowflakes

If you feel guilt at your list of unwatched shows on your DVR, this is for you.

posted @ Wednesday, August 24, 2016 10:03 AM | Feedback (0)
Tuesday, August 23, 2016
Asp.NET Core + IIS + PEBKAC = WTF, Asp.NET Core + IIS – PEBKAC = Success

Thankfully, the issue, as it usually is, was with me.

At some point, the publishOptions section of project.json switched from having an exclude section and put in an include section instead (which makes sense enough).

Turns out if you don’t include, you know, all your content and views and whatnot, IIS doesn’t have anything to serve up.

BTW, logging helps.  Duh.

Once I figured out that it was serving static content (which a helpful doc tells you to do, which requires that you read the helpful doc), it became easy to track down.

It does publish an .exe instead of a .dll, and I haven’t figured out how to publish without manual steps yet, but that tooling is supposedly coming soon, and should be workable in the interim.

Whew.

posted @ Tuesday, August 23, 2016 4:08 PM | Feedback (0)
Saturday, August 20, 2016
Asp.NET Core + net461+ IIS = WTF

So, I have my nice port/re-write of an older MVC app to the new Asp.NET Core, which depends on some parts still written in net461 and so is configured for that, and I’ve reached the point I’ve ‘dreaded’ for quite some time.

I want to host this up in EC2, like a real app, which, of course, runs IIS.

The obvious question is:  how the hell do you do that?

I’ve read many things, and still, no work-y, as they all seem to depend on ‘pure’ Asp.NET core to work.  I can look in my stdout log location and see clearly:

Now listening on: http://localhost:25458
Application started. Press Ctrl+C to shut down.

And IIS is, maybe, fronting this.  Who the hell knows.  It doesn’t actually produce any output.  View source is blank.  Since it took a while to get it to not throw a 500 error, I actually do know it was/is fronting it (it wasn’t publishing the config.json and in the back, the kestrel piece of s^&t was complaining about it).

Of course, I can run it in Visual Studio under IIS Express.  Which is, of course, useless.  I want to be able to use https, real https, across the board.  I want to surf to the site under development from various mobile devices as I develop, real mobile devices, not emulators, so I can see how things will look in the real world.  I want to have some confidence that I will be able to deploy it to EC2 successfully.

You have a decade or two investment in IIS, you’d think you’d want this to work and make it a focus, not just “well, we’ll get it to work eventually, but look, you can develop on a MacBook!”  You’d think.

posted @ Saturday, August 20, 2016 1:55 PM | Feedback (0)
Monday, August 08, 2016
I probably could have written this code better

Long-ish project converting an app of mine from Asp.Net 3/4 to Asp.Net Core (half conversion, half rewrite kind of thing) and came across this gem:


public class AttemptToChangePasswordResult
{
    public bool Succeeded { get; set; }
}

At least it is fairly clear.

posted @ Monday, August 08, 2016 7:15 PM | Feedback (0)
Tuesday, August 02, 2016
MSDN Subscription People Finally Deliver

In a follow up to this, it took a while, but they finally updated my subscription end date to reflect the period of time that I didn’t have access.  Well, most of it, I think it was technically a few weeks short but fairly close anyway.

posted @ Tuesday, August 02, 2016 4:17 AM | Feedback (0)
New Trick for Old Dogs: Count number of files in directory from command prompt

DIR /A | FIND "File(s)"

posted @ Tuesday, August 02, 2016 4:13 AM | Feedback (0)
Wednesday, July 27, 2016
Fixing ImageLink code that Asp.NET Core broke

This code, prior to Asp.NET Core, worked to create an image link:

public static HtmlString ImageLink(this HtmlHelper htmlHelper, string imgSrc, string alt, string actionName, string controllerName, object routeValues, object htmlAttributes, object imgHtmlAttributes)
       {
           UrlHelper urlHelper = ((Controller)htmlHelper.ViewContext.Controller).Url;
           TagBuilder imgTag = new TagBuilder("img");
           imgTag.MergeAttribute("src", imgSrc);
           imgTag.MergeAttribute("alt", alt);
           imgTag.MergeAttributes((new RouteValueDictionary(imgHtmlAttributes)), true);
           string url = urlHelper.Action(actionName, controllerName, routeValues);

           TagBuilder imglink = new TagBuilder("a");
           imglink.MergeAttribute("href", url);
           imglink.InnerHtml = imgTag.ToString(TagRenderMode.SelfClosing);
           imglink.MergeAttributes((IDictionary<string, string>)htmlAttributes, true);

           return new HtmlString(imglink.ToString());
       }

 

It’s usage was:

@Html.ImageLink(Url.Content("~/content/images/product/4/" + Model.Image), Model.Name, “Detail”, “Product”, new { id = Model.ID }, null, null)

Now, given that Asp.NET Core is a huge re-write, one should expect the APIs to change.  What one might not expect is that:

imgTag.ToString()

Would return the fully qualified class name, as opposed to, you know, the string representation of the content of the TagBuilder.

Why did they choose to do something this stupid (and it was a choice, this is explicitly by design)?  Who knows?  After a long day dealing with deliberately obstinate people, I don’t care.

This fixes it:

public static HtmlString ImageLink(this IHtmlHelper htmlHelper, string imgSrc, string alt, string actionName, string controllerName, object routeValues, object htmlAttributes, object imgHtmlAttributes)
        {
            ActionContext ac = new ActionContext(htmlHelper.ViewContext.HttpContext, htmlHelper.ViewContext.RouteData, htmlHelper.ViewContext.ActionDescriptor);
            UrlHelper urlHelper = new UrlHelper(ac);
            TagBuilder imgTag = new TagBuilder("img");
            imgTag.TagRenderMode = TagRenderMode.SelfClosing;
            imgTag.MergeAttribute("src", imgSrc);
            imgTag.MergeAttribute("alt", alt);
            imgTag.MergeAttributes((new RouteValueDictionary(imgHtmlAttributes)), true);
            string url = urlHelper.Action(actionName, controllerName, routeValues);

            TagBuilder imglink = new TagBuilder("a");
            imglink.MergeAttribute("href", url);
            imglink.InnerHtml.Append(GetString(imgTag));
            imglink.MergeAttributes((IDictionary<string, string>)htmlAttributes, true);

            var imgLinkDecoded = System.Web.HttpUtility.HtmlDecode(GetString(imglink));

            return result = new HtmlString(imgLinkDecoded);        }

        public static string GetString(IHtmlContent content)
        {
            var writer = new System.IO.StringWriter();
            content.WriteTo(writer, HtmlEncoder.Default);
            return writer.ToString();
        }

Note the brilliant code that requires you to decode a string that was HtmlEncoded (since you cannot WriteTo() something that doesn’t HtmlEncode it).

Brilliant.

posted @ Wednesday, July 27, 2016 9:41 PM | Feedback (0)
Thursday, July 14, 2016
The MSDN subscription people and processes need some work

So I have a Visual Studio MSDN Enterprise subscription which I’ve had since 2009 (back when it was Ultimate), which I originally subscribed to under a particular email account.

A year or two ago, I changed the Microsoft account that it was listed under/connected to/ whatever.  I don’t recall exactly, but it seems like it went fine.

This year, after I renewed it, it expired.  I called in to point out the problem and they created a ticket, and the person online noted that I had in fact paid and they did something in some database somewhere, and it was reflected in their system but would take 2 or 3 days to be reflected online.

Fast forward through 6 weeks as I spoke with 2-3 different people to deal with the same issue.  To be fair, they would often call me and say “do you have access now?” and when I told them I didn’t, they said they would do something in some database somewhere and I should see it in 2-3 days.  The last person asked for confirmation through email that I had actually renewed in the first place, and then finally, I had access.

So, I asked for my expiration date to be forwarded to reflect the 2 months I didn’t have access.

They now call me every couple of days to ask if I have access, to which I reply that I do, but my expiration date has not been updated, to which they reply that they are escalating to their subscription manager, etc.

At least they call me.  I should feel loved.

posted @ Thursday, July 14, 2016 1:09 PM | Feedback (0)
Self-care for snowflakes

If you find life so very very hard, this may contain good advice for you.

posted @ Thursday, July 14, 2016 9:56 AM | Feedback (0)