Solution: The file ‘.asmx’ has not been pre-compiled, and cannot be requested.

I had published/precompiled my site and deployed to IIS however when I try to use the service asmx I get the error “The file ‘.asmx’ has not been pre-compiled, and cannot be requested”.

In order to fix this issue I opened the “PrecompiledApp.config” and changed the updatable attribute as follows:


<precompiledApp version=”2″ updatable=”false”/>


<precompiledApp version=”2″ updatable=”true”/>

Hope this works for you too 🙂

Issue: Razor TextBoxFor returns null in Controller


I had a couple of textbox’s using razor syntax and some had an html attribute disabled in order to stop the user from editing. On Postback, the disabled textboxes kept on returning null. I made a couple of tests. At first I thought it is because I am setting the value in jQuery which was not the case. The problem is that the form ignors all disabled fields, even if they contain data. So the trick was to simply removed disabled and replace it with readonly.



@Html.TextBoxFor(model => model.username, new { @disabled= “disabled” })


@Html.TextBoxFor(model => model.username, new { @readonly = “readonly” })

How to check if user is on handheld device (mobile/tablet) using JavaScript

Just Paste the code below and call isHandheldDevice() when you would like to know. True would mean the user is on a mobile or tablet.

function isHandheldDevice() {
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))
return true;

return false;

Image Not Found Solution

It is very annoying when missing images are shown as the default broken image as it is first of all, ugly, and secondly sometimes destorts the height/width of your content. This is a very quick and easy solution:

<img src=”myImage.jpg” onerror=”this.src=’no-image-found.jpg’;” alt=”My Image”/>

Could not load file or assembly ‘ChilkatDotNet2′ or one of its dependencies. An attempt was made to load a program with an incorrect format.

Recently, we needed to migrate an old service which used Chilkat components to a new server. Even though all files were identical, the service kept on throwing the same error over and over:

Could not load file or assembly ‘ChilkatDotNet2′ or one of its dependencies. An attempt was made to load a program with an incorrect format.

Imediately, I thought of the .NET version or the dll bit version. I first checked that the application pool was running with the same old .NET version which it was. So next step was to check the dll bit version since considering this was not a new application, the dll’s were using 32-bit. To check/change what bit version the application is running on, I had to follow the following steps:

  • Open the IIS
  • Open Application pool and select the application trying to run
  • Rigth Click – Advanced Settings
  • Set “Enable 32-bit Applications” to true

This solved the issue!



ERROR: The conversion of a varchar data type to a datetime data type resulted in an out-of-range value. The statement has been terminated.

This week I was working on a migration script where I needed to run multiple sql queries. Since I was going to use this only once, I decided to use SqlHelper classes to connect and run sql to MsSql2012. Part of this included inserting and updating a date into the database. On my local computer this was working fine however, when placed on the server, I kept on getting the below error:

The conversion of a varchar data type to a datetime data type resulted in an out-of-range value. The statement has been terminated.

A sample of the Sql I was trying to use was:

UPDATE Table SET StartDate = '26-Mar-15 2:53:42 PM' WHERE ID = 15

I googled this error and amongst the top suggestions/solutions I found:

  • sql query is passing the wrong date format so it goes out of range
  • you should not pass DateTime values as sting in your SQL statement. Instead use parameters such as (    cmd.Parameters.AddWithValue("@mvendid", mVendid);  )

None of the 2 above worked. I tried all sorts of formats (“dd/mm/yyyy hh:mm:ss”, “mm/dd/yyyy hh:mm:ss”, “yyyy/mm/dd hh:mm:ss”, etc etc). I tried also declaring a new date in the sql and saving it, which still gave same error. I was about to give up when I though what about the computer’s date?


We checked my computer’s date format from “Control Panel -> Region and Language -> Formats” and noticed that the short date was completely different. Since I was desperate, we tried changing the server’s local date to match my date. Just like a miracle it worked fine.




Hope this helped … as I was going mental for a while there!!!

CSS showing overflowing text using “….”

It always annoyed me when a title or a paragraph is not big enough to fit all text and I would have to shorten it using javascript and append a “…” to show that there is more text. Now, I discovered that there is a way to do this using ONLY CSS!!!! Which I think is AWESOME…. Here it goes… very simple:

h1 {

width: 500px;

text-overflow: ellipsis;

white-space: nowrap;

overflow: hidden;



Using “overflow:hidden”, as we all should know by now, sets the overflow of the h1 (or whatever element in use) hidden, making all text outside the element hidden too. Meanwhile, “white-space: nowrap” is used to avoid having the text breaking over different lines. We want out title to fit in a line. Finally, “text-overflow: ellipsis” is telling the browser that IF there is an overflow of text, add “…” at the end of the text before the rest is hidden.

Hope this is as helpful to you as it was was for!


Error / Cause:

In .NET we have Request validation, which is a feature to prevent the server from accepting content from the client side containing un-encoded HTML. It helps to prevent client script-injection attacks submitted to a server for malicious intent. Even thought the intension of such feature is good, it can also cause some issues for us. For instance, I am trying to pass xml data in an input field and the Request validation is preventing the page from proceeding to the server.


  • When using up to .NET 2
    • Two options:
      • On the page you would like to run your un-encoded HTML, on the aspx page at the top (line 1 along with Page Language=”C#” ….) add: ValidateRequest="false"
      • Otherwise, if you would like to switch validation off globally for all pages, in your web.config under the system.web section add:
        <pages validateRequest="false" />
  • When using newer version of .NET
    • First do the either of the about to turn off validation.
    • In your web.config, find the HttpRuntime and set requestValidationMode to 2.0 as follows:
      <httpRuntime requestValidationMode="2.0"/>


This should do the trick!

Flash / Video Responsiveness while maintaining Aspect Ratio

Lets take an aspect ratio of 16:9 since it is the most common ratio for videos/media. We all know that setting width: 100% and height: 100% will make it responsive in terms of size but in terms of keeping the same aspect ratio, this is not done right. View the demo below to compare the top example (bad) and the one below it (maintains aspect ratio).


View Demo Here

And this is how simple it is to get it done, using a stylesheet or by putting a style tag at the head of the page and pasting the following:

.player-container { /* Change to Default Size - Max player size */
max-width: 640px;
max-height: 360px;
#player {
position: relative;
padding-bottom: 56.25%; /* Maintains an aspect ratio of 16:9 */
padding-top: 25px;
height: 0;
#player object, #player embed{ /* for flash / embeds */
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;


And finally, this is how it would look like in your html:

<div class="player-container">
<div id="player">


Note: player-container is optional and is only suggested when embedding in an empty page or else the whole page will be the player.


Thanks and Enjoy 🙂

Knockout.js Script1028 – Expected identifier string or number (in IE8)


Have been developing an app which uses knockout js. All seemed to work fine until I tried to test on IE8. I kept on getting an error “Script1028 – Expected identifier string or number”.

Possible Causes and Solutions:

  1. When binding using knockout js, make sure that there are no trailing commas at the end of the data-bind such as: data-bind=” text: ‘click me’, attr:{href: ‘’},
  2. When binding a javascript reserved word, such as “this, if, class”, make sure to stringify that specific reserved word. For a full list of reserved word, click here

Just an FYI, my solution was number 2, I had a data-bind=” class: ‘sampleClass’ “ and since class is a javascript reserved word this had to be written as data-bind=” ‘class’: ‘sampleClass’ “.

Hope this helped 🙂


It’s Not a Typo! Get $1.49 .COM Domains at GoDaddy!