Week 46 roundup

Last week recap and links:

Image courtesy of kanate / FreeDigitalPhotos.net

  • Scott Hanselman posted about the .NET 2015 releases. Mac and Linux, open source and visual studio community
  • Browser stack was hacked. They write about what happend on their site.
  • Net neutrality? Oatmeal replies to Ted Cruz’s tweet and explains it.

Image courtesy of kanate / FreeDigitalPhotos.net

What are your best reads this week? Leave them in the comments below.

Posted in Uncategorized | Tagged , , , , , , , | Leave a comment

Disable viewstate on IIS 7.5

We encountered a problem with viewstate encryption on Windows 2008 R2 and Windows 7. The page in question does a post with javascript to provide default values for parameters for another page. Only on IIS 7.5 this generates the error below.

[HttpException (0x80004005): Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.]

This is a feature of IIS to avoid tampering with the viewstate and cookies. The viewstate of Page X is posted to Page Y and fails the Message Authentication Code (MAC)

We don’t need the viewstate so we disable it. But even with EnableViewstate = “false” the server generated the __VIEWSTATE hidden field.

No more mister nice guy! :mrgreen: We added the javascript below in the post code to remove the viewstate. No more viewstate, no more exceptions.

TLDR

var vs = document.getElementById("__VIEWSTATE"); 
vs.parentNode.removeChild(vs);

Code from jberda answer on ASP.NET forum.

Caution

Disabling viewstate is not recommended. (Details) Use it wisely.

Posted in Development | Tagged , , , , , | Leave a comment

Chocolatey install prey

I’m becoming a huge fan of chocolatey and powershell for automation of my environment. Today I wrote a little script to complement my development environment with prey.

preyPrey lets you keep track of your laptop, phone and tablet whenever missing, whether you’re in town or abroad. Open source, proven software with hundreds of documented recoveries all around the world.

After the installation prey has to be configured. You can start the wizard in C:\Prey\platform\windows\prey-config.exe. This offers account creation and registration of your device. But what if you (like me) already have an account and the device registered?

Login on the prey website and retrieve the API Key (on account page) and device Key (on device details page). Change the values in the script below and after the installation the device is tracked again by prey.

cinst prey
(get-content c:\prey\config) |
  foreach-object {$_ -replace 'api_key=.+' , 'api_key=''API_KEY'''} |
  foreach-object {$_ -replace 'device_key=.+' , 'device_key=''KEY'''} |
  Set-Content c:\prey\config

This piece of powershell is now part of my development environment setup.

Posted in Tooling | Tagged , , | Leave a comment

Week 45 roundup

Last week recap and links:

Image courtesy of kanate / FreeDigitalPhotos.net

Image courtesy of kanate / FreeDigitalPhotos.net

What are your best reads this week? Leave them in the comments below.

Posted in Uncategorized | Tagged , , , , , | Leave a comment

Evernote coding challenge

hackerstackLast month HackerRank hosted the Evernote Coding Challenge. I participated and solved the first two tests, but failed on the next two. My rank was 66th. The price was a three-month Evernote Premium code.

Solving challenges on HackerRank is fun. They are grouped in domains like Algorithms, Functional Programming and Artificial Intelligence. You can submit your code in 30 different languages including C#. I’m hooked.

Signup is free and every developer loves to solve puzzles.

Posted in Development | Tagged , , | Leave a comment