Getting ASP.NET Core Signalr to work in IE11

Over the last couple of days I wanted to get the new ASP.NET Core version of Signalr working in a web app I am building for work. So as a starter i went to the github repository for the project found at https://github.com/aspnet/SignalR and downloaded it so I could have a look at the sample projects.

To get the project up and running you need to make sure you have .Net Core 1.2.0 beta installed and once you have that extract the project from the Zip file and run the build.cmd in the root folder. Once this is done open the solution, build the project and run any one of the sample apps (I ran the default SocketsSample).

Upon the page loading in IE11 everything looked fine until i clicked one of the links where i was then presented with some js syntax errors and nothing worked as expected. Now upon experience I know that IE11 is not the best browser around to use, but as I am developing for an Enterprise environment and we have not migrated away from Windows 7 yet this is our default browser of choice.

Being the good little developer I am ;) I have other browsers to test pages in, so i fired up the page in Chrome, Firefox and Edge and they all worked fine. I could send messages between the different browsers without any problem.

So what is the issue with IE11? Upon investigation and a bit of googling I found out that IE11 does not support es6 and this is what the Signalr project uses to compile it's typescript into js files.

Easy fix I thought, opened up the tsconfig.json file within the Microsoft.AspNetCore.SignalR.Client.TS folder and made an amendment to the target line so it read es5 instead of es6

"compilerOptions": {
"target": "es5",

Once this was done i ran the build command again and then reloaded the project. Alas, I was now presented with a new error stating that "Promise is undefined". Again a bit of googling will reveal that you need to polyfill a Promise for IE11 to understand it.

There are a number of js libraries to do this but as I had used core-js in a project for Angular2 i thought I would give that a try. Remeber to add the following to your project before loading the signalr-client.js

<script src="lib/core-js/client/shim.min.js"></script>
<script src="lib/signalr-client/signalr-client.js"></script>

So once again i rebuilt the project and loaded the hubs page, however now I realised the js in the main html files was also in es6 so babaeljs to the rescue. Just copy the js snippets from the pages into the babeljs converter and then paste the result back into the page overwriting the original code. Once again run the project to see what the outcome is.

This time however I was presented with an HTML1506 error: Unexpected Token, looking into the hub.html code the js script tags were added after the ending html tag. I moved these to just before the body end tag, reloaded and tested. Success!! I could now send messages between browser instances of IE11.

Hopefully this will help someone out and save them a few headaches along the way. Now it's just time for me to try and put this into the app i'm working on.

Until next time.

Managing the Local Administrator account in an Enterprise Environment

Recently I was tasked with creating a service that could reset the Local Admin password on workstations within our company.

It was that we didn't have a way of managing them, but after an audit it was found less than sufficient. It was using an algorithm which set the password using a mixture of date, machine name, domain name and local account to be reset. This was fine until someone put a copy of the application within netlogon and the code was disassembled and the algorithm expose therefore enabling the password to be worked out easily.

Therefore I needed to find a way of creating a random password, not too difficult, and also ensuring that this password could not be easily deciphered or guessed.

Upon doing a bit of research and googling, I came to the conclusion that using a domain pki certificate to encrypt and decrypt the password was the way to go.

The idea is that when the service starts it generates a random password, this is then encrypted with the certificate public key and the details of the workstation, date/time and the byte array of the encrypted string are written to a data base. If the database is not contactable then the password is not reset. If the local administrator account successfully logs in to a workstation then the password is reset, again this will not reset if the network is not available.

To be able to retrieve the password the general idea is to have a web page which is permissioned appropriately and the staff that require this ability can only do so through the form presented. This will be possible as the private key for decrypting the password will be stored on the web server that is hosting the pages.

This all sounds simple enough and so far i have it working successfully albeit not with the web front end but using a simple windows form application for quick testing purposes.

The source code for this will be found here https://github.com/Blankinfinity/Admin-Reset-Service , just need to upload it first but will update here when it is.

Feel free to pull the source and make amendments which could potentially improve the service and security or just leave me a comment with suggestions.


Merry Christmas

Wishing all my readers a Merry Christmas.

Things have been a bit quiet here and on the programming front for the last few weeks as things have been changing at work. We are currently going through a restructure and I am moving teams so things are a bit up in the air while I make sure things are handed over and I don't leave anything unfinished for those taking on the projects.

Saying that I will still be involved with the work just not in as much of a formal role. I have to admit i hate being pigeon holed and my new psoition allows me to get back to being more creative and coming up with ideas and solutions to put into practice that I think may benefit or help my teams and organisations.

So come the new year things will have changed over, hopefully then I will get back to making some updates on the posts i've made previously (if i don't get time over the Christamns break).

Hope you all have a good one, drink and be merry. :)

All the best

Keith


What Source Control to use?

The topic of this post is a question I have been pondering lately and would like to get others thoughts.

I have only started using Source Control solutions within the last year as before that I had never really felt the need for them. In the past I would just make an archived copy of the project before i started work on it. Obviously this still wasn't ideal but it worked for a long time, whether it was writing html, delphi pascal, c# or Asp.Net.

Working like this came to an end though when it became neccessary to start sharing code with colleagues. At this time I decided we should use Team Foundation Server as it was available for us to use. Even then once we had it installed and setup we used it more like a backup repository rather for source control.

Again this all changed when myself and some colleagues formed a mini development team. To be able to make this work properly and efficiently we needed to start using source control to our advantage. We continued to use TFS at the start but some found it a bit clunky to use as they were used to working with Git. Now being a new team and open to suggestions we found out that we also had access to an internal GitLab repo and begun working with this.

All in all i can honestly say that I have not personally had any issues with using either TFS or Git, but as I said I am pretty new to all of this and I don't have any baggage or prior use coming into this.

Now the main reason I am asking this is because I want to start making some of my code I have worked on in my own time available for others to use and make improvements if neccessary. Currently I have been using Visual Studio Online but Git does seem to be the most widely used so perhaps I'd be better off uploading my content to there? So thoughts and comments welcome, let me know what you think.


NW Updater for 1E's Nightwatchman

The company that I work for use 1E's Nightwatchman service for shutting down and waking up computers for the purpose of power saving and having greener credentials as a corporation. The service itself is great and does an amazing job of keeping our machines in a state to save energy etc and to enable us to wake up the machines in order for staff to be able to get to their desk in the morning and find their pc ready and waiting for them to login.

However I have one issue with Nightwatchman and that is its managemnet console and scripts used for adding machines to the Nightwatchman database. Obviously you could use custom scripts instead of those supplied but i thought it would be beneficial to have an application which does all of the work for you behind the scenes.

The main problems i see are that you have to compile a csv file with a list of 5 tiers and the Active Directory OU of where the computers reside. This can be very tedious and time consuming to create and update if you change things (or management want to change things) such as the tier structure or names.

So as I see it I want to be able to take an existing csv file of the tier structure import it into a datagridview. This will then ebale you to edit the fields/tiers in a more manageble fashion. From this you can then do a preview of what your tier structure will look like in a treeview control (in a similar fashion to the Nightwatchman Management console), before you commit the changes to the database.

Once i am happy with this structure I then want to be able to update these changes to the database using the stored procs or direct inserts into the Nightwatchman Staging table. When this is complete (and no error warnings have been given), it will then create the structure in the database and move the machines from the staging table into the correct tier location.

So far I have created an app which will read the csv file, create the datagridview and allow the preview of the treeview (minor tweaks needed for some UI improvements). If you would like to help or contribute to this project then please get in contact, I am pretty sure that more Nightwatchman users would find a tool like this useful.

Windows 8.1 Assigned access for Domain Users

Note: This article was originally published on an old version of my blog back in November 2014. I have reposted it here as back then a couple of people contacted me seeking further infomration as I never got around to adding screenshots. Well here it is again with them included.


I have recently been developing a Windows 8.1 application to be used in Kiosk Mode or Assigned Access Mode.

As this was to be run on a domain joined workstation and to auto login with a generic domain account I looked into whether the app could be run as a Custom User Interface set via Group Policy.

Sadly this wasn't possible as you cannot run a Windows 8.1 app directly as it isn't a win32 application.

I then tried to see that if I set a protocol in the application package manifest. This also turned out to be a non starter as even though the protcol worked a treat when logged into windows normally it could be run as a Custom User Interface directly or if launched by using cmd start (which again works if logged in normally to windows).

It was now time to try and see how Assigned Access works, so i installed the app under a local user account and logged out. Then under my administrator account I set this local account up for assigned access.

While I did this I had Process Monitor running so i could see exactly what was being changed registry and file wise for Assigned Access.

It appears that it changes settings for Windows Embedded registry entries and also create some files under the Windows -> Embedded directory.

fig 1. Process Monitor


These entries relate to the SID of the local account....interesting.

I gathered the sid of the generic domain account we want the application to run as from the profilelist in the registry and then changed the directory name and the registry entry which had the local user accountSID .

fig 2. Directory Name

fig 3. Registry Entry

So, with my fingers crossed I logged into the machine with the generic domain acocunt and hey presto, my windows 8.1 application launched as an Assigned Access App/Kiosk Mode.

Now although this worked for me in this instance I have not tried it on a fresh machine where I haven't done any other tinkering, I think that will be my job for tomorrow to put this little hack to the test.

I hope this helps some of you out who I have seen posting in forums etc asking how this could be done as Microsoft state that it isn't possible.

Give it a go and let me know how you get on.

BlogEngine.NET Migration from XML to SQL

After initally setting up my instance of BlogEngine.NET and creating a few posts etc I decided I wanted to use SQL instead.

Doing a few google searches resulted in finding this post http://nyveldt.com/blog/page/BlogEngineNET-Provider-Migration  . I followed the instructions and completed the migration with all the information I was expecting from this tool now in my database.

However, I had to run this on all Blogs residing in BlogEngine.NET and it did not migrate files I had uploaded. Therefore i decided to start writing a tool in C# which would hopefully do a complete migration. I am only in the very early stages of writing this please stay tuned for more information.

Update 11/10/2015 00:13: Have just been messing around with the front end so far and the controls it will use. This is what i have so far:

Here is the main front end where you can enter your IIS Web site location, server path and the provider from and to selections. The IIS Server details uses to FolderDialog control and the SQL Sever details uses the Microsoft.Data.ConnectionUI.Dialog. More to follow.


Keith


WMI Repository Fix

WMI seems to be used quite widely in the C# community whether it be for retrieving computer hardware information, running proccess. There is a huge list of information that you can query.

Recently I have been working on a client service which gathers computer information and enters it into a SQL database. However after rolling this client out onto a pilot group of machines i found that not all of them were reporting any information.

It looked to me as if the WMI repository on these machines was corrupt. There seem to be a few fixes (details below) out there and I have tried them without a consistent result.

So what do I do? The answer if possible is to try and write my own C# class to fix wmi and include it in the client service which unpon start will check if WMI is responding and if not will try and fix it. So far i have tried wrapping some of these other fixes within a C# class but again was getting inconsist results (i.e. After running one of these fixes on a machine WMI started to respond to some queries but not all).

I will endevour to find a solution to this issue and when i have come up with something concrete I will add an update here or in another post..

Keith


Useful Links

I have collected a huge amount of boomarks which i have found useful over the years and have decided to include some link lists which you will find on the right hand side of this blog.

There are only a few at this time but I will be adding to them frequently and I hope you find them as useful as I have.

Keith


Welcome to Keith-Pearce.co.uk

Hello and welcome.

I have decided to set up an Instance of BlogEngine.Net to enable myself to get the ball rolling for my personal website. Over the past couple of years there have been various version of this site firstly developed in php and the last iteration in asp.net mvc.

I have put the development of the asp.net ,vc site on hold for now as i just wasn't finding the time in between work commitments to do any coding. I will still continue to work on this project and will use this blog in the meantime to give updates etc.

The new site when it is finished will include information about projects that I am currently working on in work and personally, and also hope to include a knowledge base of code snippets and useful information i have discovered or found during my work or research.

So keep coming back and with any luck you will find this site useful.

Keith