How To Install Redis on Windows and Get Started With C#

Dictionary_IconRedis is a key-value store that is fast, sits in memory and runs on many different platforms. Installing on Windows isn’t straightforward from the Redis site, so below are the steps I use to get going.

1. Download the latest .zip from: https://github.com/mythz/redis-windows/tree/master/downloads

2. Extract these files to a folder (I did f:\redis)

3. In a command prompt, run

redis-server.exe redis.windows.conf

(from your directory above).

Redis should now be running on port 6379. You can change this in redis.windows.conf  if you’d like.

4. Start a new Visual Studio Project (I’m using c# / .net 4.5).

5. In Package Manager Console (NuGet) let’s install the client, run:

Install-Package StackExchange.Redis

6. Include using StackExchange.Redis;

7. Now you can use the below to save and get values:

  //setup your connection
  ConnectionMultiplexer redisConn = ConnectionMultiplexer.Connect("localhost");

 //get your db
 IDatabase redDb = redisConn.GetDatabase();

 //save a key & val
 redDb.StringSet("testKey", "test val");

 //get a key & val
 Console.WriteLine(redDb.StringGet("testKey"));

This is just start of what Redis can do, find more at the official Redis site.

How To Install Redis on Windows and Get Started With C#

IIS 8 ASP.Net Error “configuration section cannot be used…”

iis8logoWhen working with IIS 8 (or even 7 or 7.5), you may have run across this little gem / error: “This configuration section cannot be used at this path”

HTTP Error 500.19 – Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Module / Handler IIS Web Core
Notification BeginRequest
Handler Not yet determined

You’ll want to open the applicationhost.config located in: C:\Windows\System32\inetsrv\config

And now find the lines like this:

<section name="handlers" overrideModeDefault="Deny" />
<section name="modules" allowDefinition="MachineToApplication" overrideModeDefault="Deny" />

And change the Deny to Allow, like this:

<section name="handlers" overrideModeDefault="Allow" />
<section name="modules" allowDefinition="MachineToApplication" overrideModeDefault="Allow" />

Save the file, and you should be good!

IIS 8 ASP.Net Error “configuration section cannot be used…”

Setting up port forwarding in VMWare Workstation 8

To setup port forwarding (maybe you have IIS or Apache running in a VM and want to access from other machines or the host).

If you vm is setup with NAT like this:

…You can go to “Edit > Virtual Network Editor”, this brings up this:

If you choose “NAT” network type, and click “NAT Settings”, you can configure port forwarding like this:

Enter your port, VM IP, etc. Click “OK” a bunch of times and you should be good. Don’t forget about firewalls on the host and VM.

 

Setting up port forwarding in VMWare Workstation 8