Category: Uncategorized

  • System.Net.Http.HttpRequestException: ‘An error occurred while sending the request.’

    Sudenly I received a strange error in a production website while trying to do a simple http request that was working fine the previous day. The error that was thrown was the following:

       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
       at CL.Helper.Api.MailChimpController.<AddUserToList>d__5.MoveNext() 

    This line was trying to make a call to an API endpoint at MailChimp that added an email to a list. Testing the code locally and using unit testing worked perfectly and without any issue.

    After debuging the error locally I found out that the details where hiding in the inner exception that were not exposed in the logs and the issue had to do with the server not being able to create a secure channel with the client. The message was: The request was aborted: Could not create SSL/TLS secure channel.

       at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context)
       at System.Net.Http.HttpClientHandler.GetRequestStreamCallback(IAsyncResult ar)

    So investigating a bit I realised that most likely MailChimp stopped supporting older protocols and now only allowed TLS12. Good news there was a simple fix to that:

       ServicePointManager.Expect100Continue = true;
       ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

    Simply adding the two lines above before the request fixed the issue.

  • IIS 7+ Register and Execute ISAPI 32bit/64bit DLL

    I resently had to move an old project that I had from an Windows 2003 Server to a brand new Windows 2012 Server R2. The concern that I wad was with some ISAPI dlls that I was using to sync data from an SQL Server to some Windows Mobile devices using SQL Server CE. I was using merge replication to sync the devices and was doing it through the web (using sqlcesa30.dll).

    First I tried to simply copy the DLLs but that didn’t work. Then I decided to try to run the setup but that didn’t work either. That is when I started to play around with IIS to find out what is going on since I was getting that frustrating Internal Server Error (500) which gives you no clue as of what is going on!

    Here are the steps you need to take in order to register and execute a DLL on IIS 7+.

    1. Create a folder to put the the executable (this is not required but changes might affect other services running).
    2. Make that folder an application and create a new application pool for it.
    3. Open Internet Information Services (IIS) Manager and click on the server on the tree. Then click ISAPI and CGI Restrictions. There you need to add the executable you need to run and click Allowed.
    4. Then find and click the application folder on the tree and then go to Handler Mappings and then Edit Feature Permissions (which is on the right pane). There enable the Execute setting.
    5. Finally go to the application pool, select the application pool you crated and in advanced settings set Enable 32-Bit Applications to true. (this is only required if you are trying to run an x86 DLL but it does not do any harm to enable it either way)

    Hope this helps you register and run any DLL so that is at least executed and you don’t get that annoying Internal Server Error 500 that you have no clue as of what is going on.

  • Office share – Quickly and safely share links and notes with your colleagues

    IPShare.netHow many times have you sent an email simply to share a link or a note with the person next to you at the office or an internet cafe?

    Many times you will use Facebook Messenger or Google Chat or email to sent some text to the person next to you. Some of those time that person might be a complete stranger and maybe you don’t even want him/her to know your Facebook and/or email. This little web application allows you to trade small notes simply by copying and pasting your note on the page.

    It is safe, only people in your network will be able to see the notes, and you could even use a password to protect your notes from other people in your network.

    http://ipshare.net

  • Umbraco Fix – Empty recycle bin using SQL if backend fails

    Updated thanks to jeffreypriebe

    -- Uncomment below to verify the number of nodes returned is the same as the number of nodes that is in the Recycle Bin
    -- SELECT * FROM umbracoNode WHERE path LIKE '%-20%' AND id != -20
    
    --Setup the temporary table
    CREATE TABLE #temp ([id] int);
    INSERT #temp select id from umbracoNode where path like '%-20%' and id!=-20
    
    -- Delete all 'related' nodes and table contents...
    DELETE FROM cmsPreviewXml WHERE nodeId IN (SELECT id FROM #temp)
    DELETE FROM cmsContentVersion WHERE contentId IN (SELECT id FROM #temp)
    DELETE FROM cmsDocument WHERE nodeId IN (SELECT id FROM #temp)
    DELETE FROM cmsContentXML WHERE nodeId IN (SELECT id FROM #temp)
    DELETE FROM cmsContent WHERE nodeId IN (SELECT id FROM #temp)
    DELETE FROM cmsPropertyData WHERE contentNodeId IN (SELECT id FROM #temp)
    DELETE FROM umbracoUser2NodePermission WHERE nodeId IN (SELECT id FROM #temp)
    DELETE FROM umbracoRelation  where parentId in (select id from #temp) or childId in (select id from #temp)
    
    -- remove fk constraint so that umbracoNode can delete
    ALTER TABLE umbracoNode DROP CONSTRAINT FK_umbracoNode_umbracoNode
    -- delete the XML nodes...
    DELETE FROM umbracoNode WHERE id in (SELECT id FROM #temp)
    -- re add fk constraint to umbracoNode
    ALTER TABLE umbracoNode WITH NOCHECK ADD CONSTRAINT FK_umbracoNode_umbracoNode
    FOREIGN KEY (parentId)
    REFERENCES umbracoNode (id)
    
    --Cleanup temp
    DROP TABLE #temp;
    
  • Change the SQL Server Name after Changing the Computer Name

    Recently I changed the name of my SQL Server computer from the generic one given by the Windows installation to ‘SERVER’. In the beggining there was no apparent problem in the connections since I used IP addresses. After a while I wanted to use Replication and tried to create an SQL Server Publication only to find that the name of the SQL SERVER has not changed and I could not create a publication unless I connected with the correct computer name. It turns out that changing the computer name does not update the sql server name and you need to change it manually in order to be able to use replication or any other Sql Server feature that requires you to connect using the computer name!

    Below is a simple code that you can use to change the name of the SQL Server.

    sp_dropserver @@SERVERNAME
    GO
    sp_addserver 'newServerName', local
    GO

    You need to restart the SQL Server in order for the changes to take effect.

  • Umbraco IP2Location Integration Package

    IP to Location Integration PackageRecently I found a package that would help people that want to separate content of their site depending on the geografical location. It will allow you to distinguise your visitors location and therefore the content they will see.

    It can be user to differentiate or hide content depending on the users location.Let’s for example say that you have an eshop and want to promote different products to different countries this package will allow you to filter your products by country.

    An IP2Location database is required for this package to function properly which can be found on any of the sites below:

    A Database with a table filled using any of the geolocation database above is required!

    There is a trial mode that can be used on by having a sub-domain starting with development, dev, stage, test or demo.

    You can download the package and see more details here.

  • Win a lifetime Dropbox Pro account for life ($99/year)

    I believe you all know dropbox and most of you i’m sure are using it as a free account.
    Now there is a chance to win a Pro subscription for life!!! All you have to do is enter your email at the contest below…

    http://appsumo.com/ (Expires 10/13/2011)

    Good luck to you all…