No worries - just copy and paste

Three Web.config tricks - force HTTPS, force yes/no www subdomain

No worries series is designed to do just that - enable you to say "no worries", just copy the code and fire it up. For the first post in the series, we'll do two simple, but very common requirements using some web.config tricks. So, let's get into it.

Force HTTPS


<system.webServer>
<rewrite>
	<rules>
		<clear />
		<rule name="Redirect to https" stopProcessing="true">
			<match url=".*" />
			<conditions>
				<add input="{HTTPS}" pattern="off" ignoreCase="true" />
			</conditions>
			<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
		</rule>
	</rules>
</rewrite>
</system.webServer>

Sometimes you'll get a requirement to have content available only through www subdomain or without it.

Remove www subdomain


<system.webServer>
<rewrite>
	<rules>
		<clear />
		<rule name="Remove www" stopProcessing="true">
		  <match url="(.*)" ignoreCase="true" />
		  <conditions logicalGrouping="MatchAll">
			<add input="{HTTP_HOST}" pattern="^www\.(.+)$" />
		  </conditions>
		  <action type="Redirect" url="http://{C:1}/{R:0}" appendQueryString="true" redirectType="Permanent" />
		</rule>
	</rules>
</rewrite>
</system.webServer>

Read More
Php FastCGI

Handler PHP_via_FastCGI has a bad module FastCgiModule in its module list

I have seen that a lot of people visit this site when searching for:

Handler "PHP_via_FastCGI1" has a bad module "FastCgiModule" in its module list.

So, here's how to fix it.

Read More

Quick Facebook Page Tip - Post in Multiple Languages

I don't spend much time on Facebook, and I'm sad to say, even my Facebook page is not very active. Also, I'm not a social media guru, so I missed the announcement and no doubt lengthy discussions about page posts in multiple languages.

As a Croatian, who lives in Germany, but posts in English, I find this option awesome. Now I can make posts in both English and Croatian ... maybe even German, when my German gets much, much better.

So, here's how to turn it on.

1. Go to your page -> Settings

Sure you can find this, it's in the bottom right corner, next to "Help".

Read More
Speed is what we need - girl superhero speed

A few quick tips on how to improve site speed

Search engines care about page speed. Users care about page speed. It only makes sense that you try to make your pages load as quickly as possible, without losing anything important.

So, here's a few quick tips on how to do that. Let's get into it:

1. Reduce number of HTTP requests

Browsers have limitations how many parallel requests per server/proxy they do.

Firefox 2:  2
Firefox 3+: 6
Opera 9.26: 4
Opera 12:   6
Safari 3:   4
Safari 5:   6
IE 7:       2
IE 8:       6
IE 10:      8
Chrome:     6

Source: stackoverflow, you can also take a look at Browserscope.

So, what can we do about this? First thing that comes to mind is bundling. Bundling basically means that you combine all the different CSS or JS files into a single file which then browser downloads using only one HTTP request.

Read More

Development tip - Try using Visual Studio Code Snippets

If you haven't been programming in visual studio for long, chances are you haven't heard about code snippets.

Code snippet is actually code which you can quickly insert into the code editor. Typically snippets are common language constructs which you use often and a number of them come bundled with VIsual Studio. You probably noticed them in IntelliSense as you were typing code.

As the tooltip says, you can simply go to code snippet and then hit TAB key twice to insert it.

Read More

Great developer resources - Issue #1 - MSDN code samples

There are a lot of great developer resources out there on the Internets, so it occurred to me that it would be interesting to showcase some of them, especially ones that are jam-packed with great resources, such as a&nbsp;Developer code samples sub-site on MSDN.

The basic premise on this site is that everybody can upload a code sample, and then community votes on it, meaning that the best quality samples are really, really good and useful.

Read More

Functional Principles for Object-Oriented Development by Jessica Kerr

Lately I have been playing a bit with F#, mainly out of curiosity. To be honest, functional programming looks a bit scary to me, especially the syntax. But the guys over at fsharp.org and fsharpforfunandprofit.com are pretty persuasive, so I did decide to invest a bit more time in playing with it. I will see where it will lead me. Hopefully, I'll blog something concrete about #fsharp in a little while.

As a part of my journey so far I stumbled upon this video where Jessica Kerr explains the basics of functional principles and how to apply them in our "main" languages, like Java or C#. I strongly suggest you invest a bit of time and at least take a look at what it's about and how you can apply functional principles already today.

 

I really, really think you can watch the video and take away something from it immediately. It might even inspire you to try a bit of functional programming yourself.

Jessica also has a blog and she also tweets under @jessitron. I suggest you pay her a visit.

Read More

The Expert (Short Comedy Sketch)

I had to take a minute out of my day and share this wonderful and funny video about how is it like to be an engineer in a corporate world.

I really suggest that you take a few minutes to watch it.

 
Read More

Firefox Add-On of the ... month? Issue #1: HttpRequester

Let me quickly introduce an interesting add-on for Firefox to you. It's called HttpRequester and it's very very useful add-on for basically any developer.

What it does, it enables you to quickly send an HTTP request using the method which is not easily done through the browser (PUT/POST/DELETE).

You can also use a "browser view" instead of plain-text view.

Read More

Return HTTP status code 404 and error content in ASP.NET MVC

Google and all other search engines say "don't do soft 404". The proper way to return a 404 is with a 404 status code and some content that indicates that the requested page is not available. But the key thing is to return Real 404 HTTP status code and avoid any solution that replaces 404 with 301. This is completely wrong and has a potential to do damage to your site.

How to do this? Well, as always in IT there are different ways. Here's how I usually do it.

Add this to web.config:

<system.webServer>
    <httpErrors errorMode="Custom" existingResponse="Replace">
      <remove statusCode="404" />
      <error statusCode="404" responseMode="ExecuteURL" path="/Error/NotFound" />
    </httpErrors>
  </system.webServer>

Create a new Error controller with a NotFound Action:

Read More