Setting up Microsoft App Fabric for ASP.NET Session State

I had a few issues getting AppFabric setup to handle my ASP.NET session state. Here is a quick rundown of what it took. This was a single AppFabric server (Windows Server 2008 R2) in a work group, not on a domain.

  1. On your app fabric server, make a new local account called “AppFabric”
  2. Create a file share named AppFabric that gives the AppFabric user full control
  3. Install AppFabric, set the run as user to AppFabric
  4. Select the XML config provider and point it to the AppFabric Share
  5. In the start menu, there will an app fabric folder, with a windows power shell
    1. Run the power shell as administrator
    2. run the following command Set-CacheClusterSecurity -SecurityMode None -ProtectionLevel None
  6. Start your cache using the AppFabric Caching Admin Tool

That is everything on the server side. On the client ASP.NET app, it took a bit of tweaking. Here is my complete web.config file. Also note, that your Client must resolve the host name of the AppFabric server. I had to add an entry to my hosts file.

<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit http://go.microsoft.com/fwlink/?LinkId=169433 -->
<configuration>
<configSections>
<!-- required to read the <dataCacheClient> element -->
<section name="dataCacheClient"
type="Microsoft.ApplicationServer.Caching.DataCacheClientSection,
Microsoft.ApplicationServer.Caching.Core, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35"
allowLocation="true"
allowDefinition="Everywhere"/>
</configSections>
<dataCacheClient>
<!-- cache host(s) -->
<hosts>
<host
name="ServerName or IP Address"
cachePort="22233"/>
</hosts>
<securityProperties mode="None" protectionLevel="None" />
</dataCacheClient>
<system.web>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.0">
<assemblies>
<add assembly="Microsoft.ApplicationServer.Caching.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add assembly="Microsoft.ApplicationServer.Caching.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</assemblies>
</compilation>
<sessionState mode="Custom" customProvider="AppFabricCacheSessionStoreProvider">
<providers>
<!-- specify the named cache for session data -->
<add
name="AppFabricCacheSessionStoreProvider"
type="Microsoft.ApplicationServer.Caching.DataCacheSessionStoreProvider"
cacheName="Name1" sharedId="SharedApp"
/>
</providers>
</sessionState>
</system.web>
</configuration>

Tags: ,

Making forms more friendly with submit on enter

Many times when using a web form, you will want to capture the users input as they type, so that you can fire a custom function when the user hits enter, or tab.

In this example I want to submit a ASP.NET form as if the user clicked a link button, if the user hits enter while on the last form field.

To accomplish this, first lets create a function to look at the characters and check to see if it is a line break. This JS Function will then execute whatever command is passed into the second parameter.


function onEnter(input, funk) {
if (input.keyCode == 13) {
input.returnValue = false;
input.cancel = true;
eval(funk);
}
}

We then need to add an event handler to pass the keystroke data, and command to be run as the user types. This is done by using onKeyDown on the textbox. In this example, when enter is typed into the textbox, it will execute the JS function submitLinkButton passing in a parameter.


<asp:TextBox ID="LastTextBox" runat="server" onkeydown="javascript:onEnter(event, 'submitLinkButton(\'LinkButton1\')');"></asp:TextBox>

The last step of this tutorial is to emulate a asp:linkbutton click. Make sure you select ClientIDMode=”static” for the link button. When the anchor renders, the href will look something like this href=”javascript:__doPostBack(‘ctl00$Content$ctl00$LinkButton1′,”). In this function we find the anchor element, and execute whatever code is rendered in the href. This is really easy when using a JQuery selector.


function submitLinkButton(linkButton) {
eval($('#' + linkButton).attr('href'));
}

Tags: , ,

Free Content on the Kindle 3

After a few months of owning the Kindle 3, I decided to put together a post showing how I use mine, and how I get free content onto it.

Reading Downloaded PDFs on the Kindle

The Kindle 3 does support reading PDF’s naively, but their are a few problems with the build in reader. The build in PDF reader does not treat PDF files like the normal book formats. Instead of interpreting the file as text and images, It treats the whole page as an image. This means that you do not have control over the font size, and you can not use the text to voice feature. If the font size is too small (as in most cases) then you have to “zoom in” on the page, then scroll left to right. It is almost unusable in this manor.

To get around these limitations, there are a few tools available. The one that I have been using is called Mobipocket Creator. Mobipocket Creator Publisher Edition (free) allows you to open several file formats such as PDF and Word Docs, then save them in several e-Book formats. Simply  run the application, under the “Import from Existing File” header, select Adobe PDF. After selecting the file, click the build button. This will make several e-Book formats in a “My Publications” Folder.

The next step is getting the e-Book onto your Kindle. You can copy the file over using the USB cable provided, or via email. To email yourself a book, you first need to log into your Amazon account,  and approve your email address to send content to your kindle. To do this, go to amazon.com, select “Your Account”, then under the “Digital Content” header look for a link titled “Manage Your Kindle”. On this screen you can add your email addresses. Once your email addresses are on the approved list, you can email your kindle the e-Book as an attachment. The file format Mobipocket creates that is compatible with the kindle is the PRC file.

Read the rest of this entry »

Tags: , , , ,

I ask to be placed on companies no-call list. I start getting sexually harassed from sales person.

My wife and I have considered tearing down an old wooden building on our property and construction a slightly larger steel building. We decided to do a little research and find out some rough numbers of the project cost. About a week ago I filled out a form online requesting an “instant quote” from usbuildingsdirect.com.

Exactly 24 hours later I received a phone call from a sales person. This sales person, before announcing his name or the company he worked for, started asking about the weather, and if I had got all my Christmas shopping done. After stopping him and asking him who he was, he went into his sales pitch. “It’s the end of the year”, “we have inventory we have to move”, “I can get you great pricing”, “we can store the building for you”. About 15 minutes into the phone call he had still not given me any type of price. I asked him to not call again and we disconnected.

Later that day I got a call from someone stating to be his manager. After expressing my dissatisfaction, he acted concerned asking exactly what the sales person said.  I expressed that his company used high pressure sales tactics and I was not interested in dealing with them. He then hung up on me.

Everything seemed fine after that.  Although annoyed, I was done dealing with them… until today.

Read the rest of this entry »

Tags: , , , , ,

Bridgestone Golf Ball Special

4 Pack of Bridgestone Golf Balls for the Price of 3 Dozen

Today Golfballs.com launched an exclusive special on Bridgestone Golf Balls. Buy 3 Dozen of any B or e series ball and get the 4th free. The promotion is also valid on Personalized Golf Balls.


Custom Logo Bridgestone Golf Balls are also available although the terms of the special are a bit different. Offer ends August 31st.

Tags: , , , ,

My First Firearm Purchase

My Sigma

The Gun

A few weeks ago I ended up buying a Smith and Wesson Sigma 9MM Pistol. I had wanted a hand gun for some time for personal and property protection. There was a lot of unrest and rumors going around my area after hurricanes Rita and Katrina, and at the time I would have felt safer knowing that I had a firearm in my home.

I had done some research and wanted to get a Glock. When I went to Academy the showed me the S&W Sigma. The Sigma is a clone based off the Glock (so much so that Glock sued Smith and Wesson, and S&W Settled). I read reviews online and the main negative seemed to be the excessive trigger pull on the Sigma. Because of the few cons, and the Sigma being 1/2 the cost (I paid about $330 for it w/ 2 Magazines and 2 Extra via Rebate) I decided to buy the Sigma.

The Experience

Left Handed, 10 Rounds at 7 Yards

A few days after my purchase I went with some co-workers to a shooting range. I loved shooting the gun! It was my first time ever shooting a hand gun, I didn’t find it to hard to use / aim and I was happy with my shooting results. I did get to fire a few other guns while I was there. I quickly went through a 100 rounds of ammo.

I am happy with the Sigma. If I would have known how much fun I was going to have shooting, I probably would have purchased the Glock. The trigger pull causes a little hesitation when shooting, allowing the gun to wobble around a little while pulling the trigger. I found with the other weapons that had a lighter trigger pull, I was more accurate. If this is a home protection gun, it doesn’t matter that much. For something that you want to take to the range and target shoot with often, I would recommend the Glock.

Tags: , , ,

Starting and Stoping IIS7 from the Command Line

Here is a quick and simple script to allow you to start and stop an IIS app pool. I’ve used it with Windows Server 2003 and 2008. I’ve named the file AppPool.vbs, and saved it in my Windows folder (any folder in your path would be fine).

Set ArgObj = WScript.Arguments
Set objIIS = GetObject("IIS://LocalHost/W3SVC/AppPools/" & ArgObj(1))
If ArgObj(0) = "start" then
objIIS.Start
Else
objIIS.Stop
End if

It is executed by using the following commands

AppCode start [application pool name]
AppCode stop [application pool name]

Tags: , , ,

Bulk transfering data in MS SQL 2008 using BCP

Recently I’ve been playing around with SQL Azure. One of the current limitations of Azure, is no support for replication. I’ve been looking into different solutions to try and sync Azure data with my local SQL Server. The BCP utility and bulk import seem to be promising. Here is a simple example to copy the contents of a table from one DB table / server to another.

To export data to a binary data file, use the following command,
bcp "[sql query]" queryout [filename].bin -S [serveraddress] -U [username] -P [password] -d [database] -n
To import the data via the BCP utility, you can use the following command line,
bcp [table] in [filename].bin -S [serveraddress] -U [username] -P [password] -d [database] -n
Alternatively, you can also import the data via a SQL Query by using BULK INSERT
BULK INSERT  [tablename]
FROM '[path and filename]'
WITH (DATAFILETYPE='native')

To use these commands with Azure, you must be using version 10. bcp /v will tell you your version number.

Tags: , , , , , ,

Two take-aways from Managing the Grey

Recently I’ve been listing to the “Managing the Grey” Podcast.

Two take-aways that I found really inspiring:

Only Accept a project that makes you say “hell yea.” This concept reminds me of the book Free by Chris Anderson where he explains that you have a finite amount of time and money. When you are low on money and have more time, then you will do a lot of things. When you are low on time and have more money you will start to hire people to do those tasks for you (Taxes, Washing your car ect). With time being finite, don’t waste your time on projects that you are not excited about. It will drain your time, and possibly keep you from a project you really want to work on.

“Make today a good day”: CC says that he tells his children each morning to “Make it a great day.” I think that is a perfect outlook on life. Don’t wait for things to happen, make them happen. You are in control.

Tags: ,

Free Shipping Golf

I sat in on a webinar yesterday that outlined the increase in customers searching for free shipping. Most sites do not make their free shipping offers easy to find giving the customer what they are looking for.

After the webinar I purchased and setup Free Shipping Golf. My goal is to capture a large percentage of users looking for free shipping codes on golf products and drive them to Golfballs.com, especially golf gifts for the time being.

If someone searches for Free Shipping they will find a code. I rather give them the code on my own site, then have them land on a coupon site that gives them the code and also collects a commission.

Tags: , ,