Monthly Archive for August, 2009

Page 2 of 3

ASP.NET MVC Request.Files empty

Trying to get File uploads to work in ASP.NET MVC but Request.Files is always empty?

There a few things you might have done wrong!

The form tag must have enctype=”multipart/form-data” and your file input tag must have a name not just an id like below.

<% using(Html.BeginRouteForm("submission_create_path", FormMethod.Post,
 new { enctype = "multipart/form-data" })) { %>
    <input id="sourceCode" name="sourceCode" type="file" />
    <input type="submit" value="Upload" />
<% } %>

Attempting to load a 64-bit application, however this CPU is not compatible with 64-bit mode

If you get this error using VMWare ESX 4.0 it is because either your CPU does not meet the minimum hardware requirements for 64bit guest operating systems or you have not properly configured the host hardware.

The following knowledge base article describes the settings required to be enabled in the bios for both AMD and Intel CPU architectures.

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1901

Urlorize Extensions

Urlorize converts strings to Url friendly strings.

public static class UrlorizeExtensions
{
    private readonly static Regex cleaner = new Regex("[^a-z0-9 ]+", RegexOptions.IgnoreCase);
    private readonly static Regex spaceMinimizer = new Regex("[ ]+", RegexOptions.IgnoreCase);
 
    public static string Urlorize(this HtmlHelper helper, string value)
    {
        value = cleaner.Replace(value, " ");
        value = spaceMinimizer.Replace(value, " ");
        value = value.Replace(" ", "-");
        return value.ToLower();
    }
}

Usage:

<%=Html.Urlorize("test test test") %>