Digital Tool Factory blog - Backend web development in Atlanta GA

The Digital Tool Factory Blog

Something to watch for on WordPress shortcodes

The first inclination is to create a shortcode that will look like [MyShortCode]My Only Parameter[/MyShortCode], which would look like this

function MyShortCode_func($content = null){
//————-stuff happens
return $processedContent;
}

However, if you want to have parameters = you must have the $atts parameter in the function, even if it is not used.  The proper function would be

function MyShortCode_func($atts, $content = null){
//————-stuff happens
return $processedContent;
}


12
Jun 17


Written By Steve French

 

How to fix problems with password reset tokens

For some reason, asp.net identity 2 generates password reset tokens that are not property url encoded, but does send them as part of a querystring.  Therefore – when you send out the email – the web browser will add spaces to the code, which renders it invalid.  The way around that is to base 64 encode (and decode) the code as it is sent and interpreted.  Below are the Base64 extension methods.

Also – make sure there is a guid (any guid) in the SecurityStamp column in the AspNetUsers table – that will also cause it to claim that the code is invalid.

public static string ConvertToBase64(this string str)
{
byte[] encbuff = Encoding.UTF8.GetBytes(str);
return HttpServerUtility.UrlTokenEncode(encbuff);
}

public static string ConvertFromBase64(this string str)
{
byte[] decbuff = HttpServerUtility.UrlTokenDecode(str);
return Encoding.UTF8.GetString(decbuff);
}


10
Jun 17


Written By Steve French

 

How to fix problems with file creation and web deployment in asp.net

The scenario – you have an asp.net app that creates a file of some kind – everything works great – then you upload it and the file is not created.

It turns out that Visual Studio will not deploy an empty folder, or a folder that it seems as empty anyway – if the app is creating the files, the new files will not be visible to Visual Studio.  Visual Studio will see an empty folder and not create it on the server.  You will run the app, and it will try to save a file to a folder that isn’t there, and will create an error.

The easiest way to do that is to just create a blank text file in the folder.  Visual Studio will see that file, and then upload the text file (in doing so creating the folder) and the app will have a folder to create the new file in.


05
Jun 17


Written By Steve French

 

My Qnap TS-431P-US 4-bay NAS Review – Part 1

As my current backup server (the now defunct Windows Home Server 2011) is reaching end of life – I reached out to my informed tecnical brethren and all of them mentioned the QNap brand of network attached storage – that in mind, I got the QNap TS431-P – and slapped two four terabyte drives.   As it’s formatting and making beeping noieses, I thought I would write this review.

Initial Thoughts

  • Everyone and every review had good things to say about this NAS
  • The outward appearance is noting special, sort of cheap looking – the initial packaging was the same
  • While the initial hard drive installation required the use of tiny screws, there was NO slop in the snap in process
  • Two drives took about five minutes to install – that included finding the right size screwdriver
  • The initial setup (largely automated as the system downloaded files and rebooted) took about 30 minutes, with little effort on my part
  • There is some sort of app store type service – that seems to be the norm for everything these days
  • It seems fairly quiet

On the whole, I’m pretty impressed

 


01
May 17


Written By Steve French

 

What to do when intellisense stops working in java script files in Visual Studio 2015

Recently I was working on a project and noticed that none of my jquery code extension were working in Visual Studio 2015.  After much rending of garments and gnashing of teeth I discovered that the jquery code snippet plug just doesn’t work with jquery 3 – I downgraded to the most recent version of 2.0 and it all worked perfectly.


05
Mar 17


Written By Steve French

 

What to do when your web.release.config does not transform in Visual Studio 2015

Make sure that you are building in release mode – i.e. go to Build => Configuration Manager, and make sure that the relevant project is set to “Release” (like below)


03
Feb 17


Written By Steve French

 

How to do a cross domain json request with jquery and asp.net mvc web api

So – I was trying to request some data from one server from another – not normally a big deal, but the data would vary depending on whether or not the user was logged in or not.  I thought just setting up CORS would work (I’m using asp.net mvc web api 2).  I thought a simple jquery .post or .get would do the job, but surprisingly the .get and .post do not send the auth cookie when making the request – you have to use the .ajax features of jQuery, as well as enabling the “SupportsCredentials” part of Cors – the relevant parts look like this

In your web api controller

[EnableCors(origins: “*”, headers: “*”, methods: “*”,  SupportsCredentials = true)]

Your javascript code should look like this

$.ajax({
url: ‘http://MyWebServiceDomain.com/api/v.1.1/SomeController/MyFeature’,
dataType: ‘json’,
xhrFields: {
withCredentials: true
},
crossDomain: true,
success: function (authText) {
$(‘#authText’).html(authText);
}
});


19
Jan 17


Written By Steve French

 

How to fix problems with missing form values on jquery serialization

So – I was toiling away on some client side code, and noticed that a dropdown value was not being sent on a post command.  After much rending of garments and gnashing of teeth I figured it out.  I was setting the value with a .val(“something” command) – then doing the post.  It would seem that if you are doing that immediately the value is not quite in the dropdown yet (probably some DOM thing) and rather than send a null value it will omit the dropdown entirely on the serialization, and not send it on the post.

The solution is to

  1. manually add the value as an option in the dropdown
  2. then set that value with the .val() command
  3. then serialize the form
  4. then do the post.

 


31
Dec 16


Written By Steve French

 

How to fix 404 errors in asp.net web api 2

So – you’ve tried everything and you’re still getting weird 404 errors in asp.net web api 2.    You’ve tried the 4 main ways of fixing it, and you still get nothing – that was what I did anyway.  Finally I started a new project in the solution, and noticed that the problem only occured when other projects were referenced – and that I had several duplicate controller names.

I.E. Project A had and “AjaxController” and Project B had an “AjaxController”.  Everything works fine until you reference Project A from Project B – if you change the name of the controller in Project B the problem goes away and everything works perfectly.


26
Sep 16


Written By Steve French

 

How to fix the Compiler Error Message: The compiler failed with error code 255 error

Recently I was deploying some sites, and got the error “Compiler Error Message: The compiler failed with error code 255.” – which looks like this

after some research the cause of, and solution to was all in the nuget package manager.  I had recently added a new project to the solution and some of the more “stock” nuget packages were out of sync with with the newer packages.  Make sure all of the nuget packages are the same version and your problems will be resolved.


15
Jul 16


Written By Steve French

 




Copyright 2011 Digital Tool Factory. All Rights Reserved. Powered by raw technical talent. And in this case, WordPress.