Tuesday, September 18, 2018

Monday, September 17, 2018

What is Microsoft Doing?

Maybe I'm just old.
Maybe I'm just cranky.
Maybe I'm not that good.

Dealing with Microsoft, to me though, is getting old.  I love C# and many aspects of their web development stack, but I'm tired of all the false starts from Microsoft...


  • Webmatrix->Now kinda "Web Pages" in .net Core
  • MVC vanilla or Core...will vanilla be supported?
  • Web Forms...complicated and code bloat for sure, but instead of abandoning, now when the browsers are finally getting to the point where standard HTML5 is pretty much supported, Microsoft should have enhanced and slimmed down web forms and did them right.
  • Continual configuration nightmares.  Once you figure out a config setting, no big deal, but if you aren't into the art of writing / modifying config files all the time, needing an obscure setting can be pain.
  • Powershell and Unix envy.  Having it is fine, but abandoning GUI tools for it is lame.  I can just use Linux at that point and I would have a more stable OS...
  • IIS...This whole push for Core...is Microsoft going to fix IIS or just get c# to run everywhere?  To me this will translate into MS devs abandoning IIS and using open sourced C#...without attracting to much of the cross stream from the Linux dev crowd to adopt the other direction.  Dumb.  Plus again, if I want to program on Linux, I can already do that.  
  • Visual Studio seems to me to be collapsing on it's own weight.  Creating a simple web project now produces like 500 files with 10 folders and all sorts of again config bull sh*t.  Just to say hello world.  I get tired of the seemingly .5-1.5 gig bi-weekly updates to Visual Studio as well.  Come on guys, get your stuff straight.
  • Entity framework...ambitious idea, I got it to work, but not without it's quirks.  Slow as balls though for high scale apps unless you get in and start tweaking the frack out of things. 
  • Azure...I actually use Azure for home projects, but for professional development I, at least right now, could care little about it.  No way the enterprise stuff I work on is ever going into "the cloud".  So I get worried when I see the latest round of Microsoft Certs all seeming to contain Azure test questions.  I have no problem with Microsoft having a set of Microsoft Azure certs, I mean by all means of course.  But to FORCE Azure knowledge everywhere in order to remain certified pisses me off.
I don't know.  Programming to me seems like a lot of fads for smart people.  Web development is taking data from a user and / or displaying data in a meaningful way with security.  You can make that as complicated or as simple as you want.  It seems like just when web development was becoming fun again (HTML5 stabilizing, not having to write as much separate client code for browser exceptions, lot's of client side frameworks to do animations and such with) my dev stack, Microsoft, exploded.  

Kind of a bummer.  Especially with so many things C# / .Net do right.  Again maybe I'm just getting old and suck, but it seems like with the Microsoft stack lately I struggle with my tools rather than providing solutions.  That bugs me.  I'm looking for something lighter.  I'm not 18 any more where I enjoy jumping over hoop after hoop to get something to work, especially when in the past it seems things were much simpler and easier to get things done.  

I know Waaa right?

I really liked the MVC / SQLite in wal mode on IIS stack.  Though I only used it a few times it worked for me and I was productive in writing quick little web apps.  .Net Core MVC less so. I guess I will explore Core web pages and see if they are light.  I'm also looking at doing somethings in the ancient LAMP stack,maybe just to give me some perspective and possibly provide some backup skills in case Microsoft goes off the deep end.  I'll probably pick up Node again as well.  Ruby?  Naah...Python?  Maybe.




Tuesday, March 06, 2018

Coda Obsura: Getting the selected items of a Telerik Kendo ListBox.

Maybe I'm missing something.  But I don't see any javascript API for getting the SELECTED items in a kendo listbox.  I'm just binding to a string list that I pull with a read.  I ended up having to get the items using jquery hunting them down by the selected style.


  $('#mylistboxname').prev("div").find('ul').find('.k-state-selected').each(function () {
    myarray.push($(this).text());
  });

Tuesday, January 30, 2018

Adding to, and Accessing, Properties on the ApplicationUser Class in ASP.Net Core 2.0 MVC

Ok, this is actually really simple to do, but frack me if it didn't take me awhile to figure things out.  Note for this example we will use a code first approach just to show the concept.

Step 0: Create a new core MVC project, select the option for authentication called something like "store credentials in application" (I'm updating VS Studio right now so going on memory).

Step 1: Add whatever properties you want to the ApplicationUser class, stuff like

public string SomeField {get; set;}
public string SomeOtherField {get;set}

Save

Step 2: from the nuget console, run add-migration , give it a name.

Step 3: from the nuget console, run update-database

When done you can use whatever to see the table with the new fields (In VS sql server object explorer).

Optional: You can tweak all the view and manage models to support your new fields.  I didn't for now.  I just went in and gave one of my new fields a value.

Step 4: Tweak you controller and inject the usermanager into your controller.
 
a) include using Microsoft.AspNetCore.Identity; and maybe the namespace of where you models reside.

b) Add a private usermanager variable to your controller like so-

    private readonly UserManager _userManager;

c) Then on your initialization method, inject the usermanager.  If your controller is names HomeController it would look like this-

public HomeController ( UserManager userManager )
    {
      _userManager = userManager;
    }

Step 5: In your controller you can now access the added properties to your user like so (in this example I added PersWeboptionsText to the field  ApplicationUser class.

  // test for a given value...
      var weboption = _userManager.GetUserAsync( User ).Result?.PersWeboptionsText;


YAY!  Now you can use and abuse that value to do whatever.


But what about in a view?  Are we stuck always passing that value in as ViewData or something?  No, you can use a similar approach.  You must inject the user manager into your view (or into your _layout.cshtml file at the top like of the view like so-

@inject UserManager UserManager


Ok, now in your page to access customer ApplicationUser properties/fields, again using PersWeboptionsText as an example field added to ApplicationUser, you can do so like this-

@UserManager.GetUserAsync( User ).Result?.PersWeboptionsText


That should get you going.  Next up is adding collections to the ApplicationUser and making sure they populate right.

I should come back and reformat this post and make it pretty...ain't nobody got time for that.

Happy Coding.