Using the wpp.targets file together with Sitecore

Posted on

When working on Sitecore and deploying modules to a Sitecore site we only want to deploy artifacts that are ours and not from Sitecore. This way we want to keep the deployment packages clean and fast. To manage the contents and behaviors of deployment packages we can use a wpp.targets file. The project setup We use Unicorn to serialize […]

Use Sitecore analytics to show number of pageviews

Posted on

You probably have on sites with pages that show how often these are visited. This is done to show visitors that the page has attracted more people to read it and encourages them to read the article as well. This blogpost has been written using Sitecore 8.2. In older versions of Sitecore, different solutions can be used. […]

Social login with OWIN Authentication in MVC5

Posted on

MVC5 came with some really nice stuff. In this blog post I’ll dig into the authentication with external logins as Microsoft calls them. We call them often social logins. The way this is done is quite different than in MVC4. Where MVC4 depended on webmatrix MVC5 makes use of OWIN security

Best practices to version Web API

Posted on

Once you publish an Web API, it’s set stone. Publishing an API is not a trivial move to do. Users or customers rely on the API not changing after publishing. But however requirements will change always. So there’s a need to evolve the API without breaking existing clients.

SignalR to synchronize web pages real-time

Posted on

What is SignalR In a nutshell, SignalR allows you to pass data between client and server in realtime. It will run on .Net 4.0 or 4.5 and to get websockets running, you will need IIS8 or IIS8 Express. That said, it will run on older versions of IIS and will switch to different transport modes.

When to call EnsureChildControls in custom controls

Posted on

Should I call EnsureChildControls in code? It depends on different scenarios. Actually, EnsureChildControls method determines whether the server control contains child controls. If it does not, it creates child controls. This method first checks the current value of the ChildControlsCreated property. If this value is false, the CreateChildControls method is called. ASP.NET calls it this […]

Invalid postback or callback argument. Event validation is enabled

Posted on

I wrote web part that uses Repeater control to create some repeating blocks of output. Each of these blocks has Button control in it. When I ran web part under SharePoint I got the following error: Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation=”true”/> in configuration or <%@ Page EnableEventValidation=”true” %> […]

Exclude code from test coverage and code analysis

Posted on

When working with generated code, I don’t want this to affect my code coverage, code metrics or code analysis. All these statistics are interesting over code that really matters. To exclude generated code from these statistics you can use a few attributes. GeneratedCodeAttribute, this will exclude the code for code metrics and code analysis. It […]

WCF Dispose problem with using statement

Posted on

WCF client cannot be used inside a Using block because they may unexpectedly throw an exception. Even if you catch the exception, it is possible that a connection will be left open. Why is this IDisposable implementation so different from all the others in the .NET Framework. The first problem with WCF clients is that […]

How to download MemoryStream as a file in zip

Posted on

Using the SharpZipLib it’s possible to zip and unzip files. This can be a good solution when file size matters. Downloading files that are ziped can save many bandwidth. In this case a object is serialized to XML and put into a ZipOutputStream which belongs to SharpZipLib. public static byte[] RetreiveBytes(IEnumerable<int> Ids) { MemoryStream stream […]

Using the XmlSerializer in multithreaded applications

Posted on

The XmlSerializer can cause serious problems in multithreaded environments. See this piece of code. [ThreadStatic] private static XmlSerializer xmlSerializer = new XmlSerializer(typeof(Mailpack), Namespace); private static string SerialiseAssemblageResultaat(Mailpack mailpack) { StringBuilder xmlString = new StringBuilder(); TextWriter xmlWriter = new StringWriter(xmlString); try { xmlSerializer.Serialize(xmlWriter, mailpack); return xmlString.ToString(); } finally { xmlWriter.Close(); xmlWriter.Dispose(); } } What we see […]