Initial Look at .Net Core

In the last 2 days I have done something new and jumped straight from the diving board and into the pool that is the .Net Core. No more researching and thinking about it just going to dive in and code a few things, watch some videos as I go and all the research will be inline with a project or purpose. Trying to avoid that analysis paralysis that I have so awesomely perfected…

To start, the .Net core isn’t too much different than .Net, really (duh!)… C# is still my language of choice and I have created two applications and dissected them to the point of being able to show someone how to write them on their own already. The one application is the famous “Hello World!” that every programmer has to do at least once just to see it. Then, of course, I had to dive into the web realm a little and see what trouble I can get in there. I wrote a standard ASP.Net Hello World application to see the beginnings of the web architecture. So far, so good.

Getting started I looked at the following site: .NET Core

I also had already installed Visual Studio Code from a previous use of the editor. I did update it before I started this process. I also told myself that for better or worse I would stay in VSCode for all of my workings for the time being to give it a fair shot. This turned out to be a big distraction in and of itself as I got caught up in git within the editor.

I know, me get caught up in git… Who would have thought?!?

What I have found is the following:

  • .Net Core on Mac has no more hand holding… Meaning the code is mind to write and there isn’t much to the project templates as without yeoman there isn’t much of a template.
  • Web applications still had the Program.cs and a Main method… Weird… I didn’t expect that.
  • Not having openssl led to a couple issues in the beginning. I didn’t expect this and plan to research this a little more.
  • command sequence = dotnet new -> dotnet restore -> dotnet run
  • Git appears fairly well integrated but has a few options that can get you in a lot of trouble (anything where you can undo… NO! WHY?!?! undo changes history, you shouldn’t try to rewrite history)
  • Current materials for the stuff are lacking and I can’t wait to attack this with a few friends!
  • If you want templates there is this thing called Yeoman which is next to play with
  • I also get to figure out Bower, Grunt and Gulp as they are installed as part of the tutorial I am going through.

so far I have to say I am not as big a hater on VSCode as I once was. Don’t get me wrong, it is still just a text editor but the fact that I can use the terminal inside the editor and I can navigate multiple solutions, play with git (basics -> add, commit mainly) is a bonus.

For those looking to get a start I would start with the .NET Core link above. Make sure that you get VSCode installed and ignore Yeoman, Gulp and Grunt and all the other stuff until you have something working. Then you can play with more toys. It’s like any good collectible game, start with the base set first. Make sure you learn how to play and that you like it before you go buying (installing) all the other expansions (features).


You can count on more to come here… I’m just getting started.

Hosting ASP.NET on Shared Hosting Site

Within the last few weeks I decided to take the venture of moving my host provider from one web hosting company to another. At the same time I decided that I wanted to do Windows hosting going forward so that I could host ASP.NET applications. I figured this would be easier since I know more of C# and .NET than I do PHP and the linux web hosting technologies. Boy, was I wrong…

So the first issue was with the domains. Normally when you transfer domains from one provider to another it can take up to 7 days. For some reason one of my domains transferred in what felt like hours. Instead of a week I received the email that the domain transferred in a day or two. Although I received an email that the domain transferred and it showed on the new provider, the old provider also still displayed the domain. Thus when I deployed my new website and all the files to the new provider it would sometimes display the old provider. Awesome times…

Once that was straightened out my new site starting throwing a 403 – Forbidden error anytime that I browsed to the page. The 403 error seemed consistent but then when I deployed my solution would work and I could browse to the pages without issue for a few minutes until the 403 error would resurface. Contacting the host provider the 403 error appeared to be caused by settings on the server. This lead the provider to ask me to change several things in my web.config file as well. This included code to add the following:

<modules runAllManagedModulesForAllRequests="true"></modules>

This seemed like a bit of overkill. This also did not fix the issue either. Instead the error continued and given that this didn’t seem to work, I reviewed other solutions and suggestions made online and replaced the above with:

<remove name="UrlRoutingModule~4.0" />
<add name="UrlRoutingModule~4.0" type="System.Web.Routing.UrlRoutingModule" preCondition=""/>

Although this code seemed to directly address the issue, it didn’t work either.

The issue at this point was diagnosed to be with ASP.NET and more specifically the MVC routing within. None of the views were being properly executed and the controllers were never being reached. No matter what I did the error would not cease as every time I deployed it worked for a while and then around 30 minutes later it would go back to 403 – Forbidden.

The issue turned out to be an issue with the precompile setting on the publish settings dialog. Below is the settings dialog.

Visual Studio 2015 Publish Settings Dialog
Visual Studio 2015 Publish Settings Dialog

The second checkbox was causing the issue. For some reason checking this box would cause a security issue that would prevent the MVC Routing for executing properly.

Maybe next time I will realize the shortcut isn’t worth it…

New to Git… What is git?

Git is a source control management system, hence By source this actually refers to any file of any type. We can add any file that we want to the system and begin tracking modifications to that file. As we create other related files we can add those to the system as well. This means that we can organize a group of files together and track them as a whole. From the perspective of a developer we can think of this as our source files for a project we are coding. For instance, in a C# project this would be all the .cs files. Now this grouping of files actually has a special name as well, a repository. Let’s review:

git – source control management software that tracks the modifications to one or more files

source – a file that we wish to track modifications through the software

repository – a group of files organized into a single set and tracked together as one group.

So how does git work? Well, let’s think about this in terms of the computer we are on and the file system that the computer has. A computer has a file system and consists of files and folders. Those files and folders are created to provide a desired structure so that we can easily find files that we are searching for. Git uses this structure for its repositories. A repository is really nothing more than a folder with files and other folders that we wish to track within the repository. Although, only the files are really being tracked for modifications, the repository can contain subfolders as well. A repository exists locally then and can be thought of as being on the machine we are working on. Therefore any modifications we make would be done locally on the computer we are working on.

So wait… we are going to work with everything locally? but what about portability to other machines, collaborating with other developers or just saving a copy to a central location so that if our machine’s hard drive is lost we don’t lose all our changes. Git solves this too… Git has the concept of a remote repository as well. A remote is a location that we intend to copy our changes to periodically. This could be another server within the network, an online host (such as GitHub or Bitbucket) or really any other directory that we want to copy the local repository. Our only interaction with this remote will be to copy (push) changes and retrieve (pull) changes from the remote. The remote itself will be a repository but one we won’t directly modify. Instead we work locally and push those changes that way.

Let’s take a look at a possible structure here.

Let’s start with a _repos folder. This folder will not be a git repository but instead be the folder that we create all our other repositories in. This way if we need work in more than one repository at a time we can differentiate between them using separate folders within this folder. For instance:

+ _repos
|-+ project1
|-+ project2

In this example we have two projects. Each directory, project1 and project2, are both git repositories. They are different repositories tracking files for two completely different projects. If we need to start working on another project we would just create another directory. The important thing is that we not put a repository within the folder of another repository (this is something more advanced and if we are just starting out, it is best to avoid). So we would never put project2 folder inside of project1. All the repos would go inside the _repos folder.

Once we get the folder structure of git we have a good base level knowledge to get setup and get git going with the basic commands… something I will save for another post.

Git Repository in a Repository Fix

In working with apprentices new to Git and really new to source control in general, I have come across a couple cases where someone will have a repository defined within a repository. In these cases the parent repository is not tracking the files within the subdirectory and there appears to be nothing that can be done to resolve this. To paint a better picture let’s work with this example:

+ sub_project

In this example there is a .git directory within both the project folder and the sub_project folder. Thus Git believes that these are separate repositories and in fact by design, although not correctly defined, believes that sub_project is a submodule of the project repository. I say not correctly defined since it cannot be found in a .gitmodules file. It only appears to be a submodule. We would have some work to do if we wanted it to be correctly defined. However, in the simple case we don’t want to do this and instead want to remove the repository from the subdirectory.

To fix the issue we need to delete the .git folder in the sub_project directory. We also need to remove the directory from the index of the project repository so that we may re-add the directory and be able to track the files within the sub_project directory in the project repository. To do this we can run the git rm sub_project command. Thus to fix the issue:

1. delete the .git folder from the subdirectory
2. run git rm sub_project
3. re-add the sub_project directory to the project repository
4. commit

Now things should be ok and we should be able to continue using our project repository with no issues. We just need to be careful not to create repositories within the project directory unless we really want to have submodules.

UPDATE: 9/11/2015

In doing this again I did have to run git rm with the --cached

git rm --cached sub_project

My Git commit isnt adding my files…

In some cases you may run the git commit --all command and think that it will stage and commit all the changes, deletions and new files that you have in your project. The truth is in the documentation of the git commit, though…

git commit documentation


Tell the command to automatically stage files that have been modified and deleted, but new files you have not told Git about are not affected.

This means that in order to add new files to the repository you can’t just run git commit. Instead you have to run git add and then git commit.