Skip to main content

Posts

Quick and easy table Audit with code first EF6 and Migrations

For one of my current projects, we had a requirement to create track changes made to two tables in the database for auditing purposes. Initially I thought we could just use the built in SQL change tracking features ( here ), however we were deploying this application to Azure and as of now, that feature is not available in SQL Azure. I did some investigating into this and there were a few options: Option 1: Create my own triggers on these tables and write data to the audit tables when the rows were updated. This was some what straight forward, but I’m not a fan of triggers and I wanted to keep all of my code in C#/Entity Framework for ease of code management down the road. Also, I didn’t want to have to update the triggers when the table was altered Option 2: Implement this work around leveraging a Local data cache While this seems like an easier approach, I wouldn’t be fully in control of what was happening during updates. Also, this approach only tells you what rows have cha...

Sitefinity Blank Login Screen

  One on of my current projects, we’re leveraging the Sitefinity CMS for our front end. Initially the setup went really smoothly and I was off to the races. There is a ton to learn and a lot of the functionality is fairly intuitive. I was super excited about it until I tried to deploy some code updates to our Development/Integration Server. We had already created a site on the development server directly and I didn’t need any of the content that I had created locally, so I figured it would be as easy as moving my code out to the DEV server. When I did this and went to fire up the site, I got a blank Login screen: We went back and reviewed the windows roles/features that need to be turned on and everything seemed to look fine. I recopied the code over and over with no success. Finally we did a folder compare between the initially deployed site on the DEV server and the code that I had moved. The only thing noticeable was that the GUID’s in some of the configuration files where...

Build/Deploy Windows service with TFS

Building and deploying a web service or website via TFS is pretty straight forward, but automatically deploying a windows service or console application takes a b it of setup. I’ve outlined the steps below to get your service deployed. Step 1: Set up Automated Build and MSDeploy on the Target server. If you are doing any sort of automated build/deploy I recommend using MSDeploy. You can follow steps 1-3 from a previous post here . Step 2: Edit the .csproj file The project file for the app you are trying to deploy needs to be edited so that TFS will create a directory for the output of the project. Otherwise the project will be built, but the assemblies will be placed in the code drop location with no organization to it. To edit the file, go to the open file dialog and locate the csproj file. Select it but don’t click “Open. Instead click on the dropdown arrow next to the Open button, select “Open with”, and choose the XML (Text) editor as shown: Once the file is open, add the fo...

Checking Server to DB connectivity easily

We’ve all been there before. We set up our new web or application server with the latest code, update the connection strings with the proper SQL Server instance and password and fire up the application only to see all sorts of SQL connection/login issues.  These issues can be very frustrating to troubleshoot because you are not sure if the Login is incorrect, the db is spelled incorrectly or if there are network issues preventing you from seeing the SQL Server. On windows machines, there is a simple way to validate that the SQL server is accessible from the server. Remote desktop into the server having connection issues Click on “Start” and search for Folder Options. Click on Folder options, go to the View tab and validate that the “Hide extensions for known file types” is unchecked:   Go to the desktop, right click and select New –> Text Document Rename the file connection.udl and accept the rename warning Double click on the udl file and it will open the Data Li...

MSDEPLOYAGENTSERVICE 401 unauthorized–Resolution

We recently migrated a production environment for a client to new Servers. I had previously been using MSDeploy to deploy the websites/services to the servers so I figured all I had to do was install MSDeploy, point Update my deploy scripts to point to the new servers, and deploy! I was using MSDeploy 2 on the previous servers so I figured it would work on the new ones. Unfortunately it didn’t turn out to be that easy. When I ran the updated scripts I got the following error: Fatal: Request to remote agent URL ' http://myserver/MSDEPLOYAGENTSERVICE ' failed. Fatal: The remote server returned an error: (401) Unauthorized. Fatal count: 1 I was using an admin account and I could hit that URL above in a browser so I knew it wasn’t an authorization issue. Here are the things I tried that DIDN’T work: Uninstall/Reinstall MSDeploy 2 Install MSDeploy 3 Create the fake user group on the server per these instructions: http://www.iis.net/learn/publish/troubleshooting-web-dep...

Keep a website alive – PowerShell style

  Recently, We had a website that didn’t have frequent visitors, but when the visitors did come, the website would take a long time to load up the first time. This is expected behavior because IIS shuts down its worker threads. 1 approach would be to set the IdleTimeout to 0 which means the threads are never aborted (details here: http://technet.microsoft.com/en-us/library/cc771956(v=ws.10).aspx ). Instead of that though I decided to try my hand at PowerShell and came up with the following script: 1: # List of URLS to Ping 2: $urls = @( "Http://URL1.com" , "https://URL2.com" ) 3:   4: #Ping all URLs in the list 5: foreach ($objItem in $urls) { 6: $req=[system.Net.HttpWebRequest]::Create($objItem); 7: $res = $req.getresponse(); 8: $stat = $res.statuscode; 9: $res.Close(); 10: 11: #Pump it out to a text file 12: $res | Out-File pingresults.txt -append 13: } After that I set up a simple ...

Searching the Visual Studio Toolbox

  Ever want to add a control to the design surface, but you have so many controls that you have a difficult time finding them? I was shown this neat shortcut that has saved me a lot of time over the past few days. Click on the toolbox or use the Hotkey Alt+Ctrl+x Start typing the name of the control. The control will be highlighted If you have multiple controls that match the text, hit Tab to go to the next one. Simple and easy!