<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Recent Articles</title><link>http://www.joel.net:80/</link><description>Recent Articles</description><item><title>MiniLinq for Script#</title><link>http://www.joel.net:80/minilinq-for-script-sharp</link><description>&lt;p&gt;&lt;a href="http://projects.nikhilk.net/ScriptSharp"&gt;Script#&lt;/a&gt; is my new favorite piece of technology. Write JavaScript with C#? Yes please! But since it's (currently) limited to ISO-2 C#, it can feel like you're stuck back in 2004. Using C# 2 means you're missing a lot of things you use daily... like LINQ. I do miss LINQ. So I read about &lt;a href="http://www.nikhilk.net/ScriptAndLINQ.aspx"&gt;Script# adding a few LINQ like extensions to the array class&lt;/a&gt;&amp;nbsp;and decided to work them together into this MiniLinq class, which I am now sharing with you.&lt;/p&gt;
&lt;h2&gt;Some examples&lt;/h2&gt;
&lt;p&gt;This works with objects too, I'm just using int for simplicity.&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;int[] numbers = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

// [2, 4, 6, 8, 10]
int[] evenNumbers = (int[])MiniLinq
    .From(numbers)
    .Where(delegate(object o) { return (int)o % 2 == 0; })
    .ToArray();

// [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
int[] descendingNumbers = (int[])MiniLinq
    .From(numbers)
    .OrderBy(delegate(object x, object y) { return x == y ? 0 : (int)x &amp;gt; (int)y ? -1 : 1; })
    .ToArray();

// [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
int[] doubledNumbers = (int[])MiniLinq
    .From(numbers)
    .Select(delegate(object o) { return (int)o * 2; })
    .ToArray();

&lt;/pre&gt;
&lt;p&gt;I'm calling it MiniLinq because it's only a partial implementation of LINQ. To be more accurate, it's just the methods I need to use for my project. Until there's an official implementation in Script#, this is what I'll be using. If you want to download or extend MiniLinq, &lt;a href="https://gist.github.com/970138"&gt;check it out on github&lt;/a&gt;. Share your changes with me!&lt;/p&gt;</description><pubDate>Mon, 07 May 2012 05:07:57 GMT</pubDate><guid isPermaLink="true">http://www.joel.net:80/minilinq-for-script-sharp</guid></item><item><title>Unobtrusive Data-Binding for Knockout.js</title><link>http://www.joel.net:80/unobtrusive-data-binding-for-knockout-js</link><description>&lt;p&gt;If you're a web developer who has yet to see Knockout, &lt;a href="http://knockoutjs.com"&gt;go take a look&lt;/a&gt;. I'll wait... Knockout is an incredible library, I just love it. Though I prefer to keep my presentation layer clean and now it's sprinkled with little bits of code for the data-binding. And that is how this &lt;a href="http://gist.github.com/1006808"&gt;Plugin&lt;/a&gt; came to be. It solves that problem with an easy way to &lt;span style="text-decoration: underline;"&gt;Unobtrusively&lt;/span&gt;&amp;nbsp;Data-Bind your presentation layer.&lt;/p&gt;
&lt;h2&gt;Obtrusive example (taken from knockoutjs.com)&lt;/h2&gt;
&lt;p&gt;You'll notice in this example, information about how to perform the data-binding is married to the presentation layer.&lt;/p&gt;
&lt;pre class="brush: html;"&gt;Choose a ticket class:
&amp;lt;select data-bind="options: tickets, 
                   optionsCaption: 'Choose...',
                   optionsText: 'name',
                   value: chosenTicket"&amp;gt;&amp;lt;/select&amp;gt; 

&amp;lt;p data-bind="template: 'ticketTemplate'"&amp;gt;&amp;lt;/p&amp;gt; 
        
&amp;lt;script id="ticketTemplate" type="text/x-jquery-tmpl"&amp;gt; 
    {{if chosenTicket}}
        You have chosen &amp;lt;b&amp;gt;${ chosenTicket().name }&amp;lt;/b&amp;gt;
        ($${ chosenTicket().price })
        &amp;lt;button data-bind="click: resetTicket"&amp;gt;Clear&amp;lt;/button&amp;gt;
    {{/if}}
&amp;lt;/script&amp;gt; 
    
&amp;lt;script type="text/javascript"&amp;gt; 
    var viewModel = {
        tickets: [
            { name: "Economy", price: 199.95 },
            { name: "Business", price: 449.22 },
            { name: "First Class", price: 1199.99 }
        ],
        chosenTicket: ko.observable(),
        resetTicket: function() { this.chosenTicket(null) }
    };
    ko.applyBindings(viewModel);
&amp;lt;/script&amp;gt;	
&lt;/pre&gt;
&lt;h2&gt;Unobtrusive Example&lt;/h2&gt;
&lt;p&gt;But now the data-binding has been completely separated from the presentation layer.&lt;/p&gt;
&lt;pre class="brush: html;"&gt;&amp;lt;!-- file: ticket.html --&amp;gt;

Choose a ticket class:
&amp;lt;select id="tickets"&amp;gt;&amp;lt;/select&amp;gt; 

&amp;lt;p id="ticketOutput"&amp;gt;&amp;lt;/p&amp;gt; 
        
&amp;lt;script id="ticketTemplate" type="text/x-jquery-tmpl"&amp;gt; 
    {{if chosenTicket}}
        You have chosen &amp;lt;b&amp;gt;${ chosenTicket().name }&amp;lt;/b&amp;gt;
        ($${ chosenTicket().price })
        &amp;lt;button data-bind="click: resetTicket"&amp;gt;Clear&amp;lt;/button&amp;gt;
    {{/if}}
&amp;lt;/script&amp;gt; 
&lt;/pre&gt;
&lt;p&gt;and the javascript file...&lt;/p&gt;
&lt;pre class="brush: javascript;"&gt;// file: ticket.js

var viewModel = {
    tickets: [
        { name: "Economy", price: 199.95 },
        { name: "Business", price: 449.22 },
        { name: "First Class", price: 1199.99 }
    ],
    chosenTicket: ko.observable(),
    resetTicket: function() { this.chosenTicket(null) }
};
 
$('#tickets').dataBind({
    options: 'tickets',
    optionsCaption: "'Choose...'",
    optionsText: "'name'",
    value: 'chosenTicket'
});
 
$('#ticketOutput').dataBind({ template: "'ticketTemplate'" });
 
ko.applyBindings(viewModel);
&lt;/pre&gt;
&lt;h2&gt;The Advantages / Why&lt;/h2&gt;
&lt;p&gt;&lt;b&gt;Complete separation of code from your presentation layer&lt;/b&gt; -- There are many reasons why you might want this: Code can be kept in separate js files (think of caching), designers can now modify the html without worry of breaking it, etc. &lt;b&gt;Elimination of magic strings&lt;/b&gt;-- Complex data-binding can be difficult to maintain with magic strings, especially when you start using functions or events. In the following example, I took the data-bound element from above and added a click event. Without the Unobtrusive approach, you'd have to encode that function into your magic string.&lt;/p&gt;
&lt;pre class="brush: javascript;"&gt;$('#tickets').dataBind({
    options: "tickets",
    optionsCaption: "'Choose...'",
    optionsText: "'name'",
    value: "chosenTicket",
    event: {
        change: function(evt) {
            console.log(evt);
        }
    }
});
&lt;/pre&gt;
&lt;h2&gt;Download it&lt;/h2&gt;
&lt;p&gt;Well that's pretty much it. The Plugin is small at only 544 bytes (360 bytes gzipped). Download it and play with it. Let me know if you find any bugs. You can download it here: &lt;a href="http://gist.github.com/1006808"&gt;github&lt;/a&gt;&lt;/p&gt;</description><pubDate>Mon, 07 May 2012 04:24:14 GMT</pubDate><guid isPermaLink="true">http://www.joel.net:80/unobtrusive-data-binding-for-knockout-js</guid></item><item><title>Generic IQueryable Repository for Entity Framework 4 (EF4)</title><link>http://www.joel.net:80/generic-iqueryable-repository-for-ado.net</link><description>&lt;p&gt;Anyone who has tried to create tests with Entity Framework (EF) knows that EF is not very unit test friendly. I needed something simple, reusable and unit testable. this generic repository was the result.&lt;/p&gt;
&lt;p&gt;The goal of this project was high reusability, ease of implementation and to be unit tests friendly.&lt;/p&gt;
&lt;p&gt;There are a lot of Repository Pattern's out there that hide a lot of the underlying functions of your data access layer (in this case LINQ). Well, I really like LINQ to SQL and didn't want to hide any of that. Plus, if you really need encapsulation it should be done in your service layer and not your repository layer.&lt;/p&gt;
&lt;h2&gt;Some Quick Examples&lt;/h2&gt;
&lt;p&gt;remember to add "using System.Linq"&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;IRepository&amp;lt;Log&amp;gt; logs = new Repository&amp;lt;Log&amp;gt;(new MyDataContext());

// use LINQ
var items = from l in logs.All()
            where l.LogType == "Error"
            orderby l.LogId descending
            select l;

// load an item
var item = logs.All().Single(l =&amp;gt; l.LogId == 1);

// update an item
item.TimeStamp = DateTime.Now;
logs.Save();

// create an item
item = new Log {
    TimeStamp = DateTime.Now,
    LogType = "Information",
    Message = "This is a new Log!"
};

logs.Add(item);
logs.Save();

// delete an item
logs.Remove(item);

// Eager Loading
items = from l in logs.All("Details")
        select l;

&lt;/pre&gt;
&lt;h2&gt;Repository Code&lt;/h2&gt;
&lt;p&gt;The code is pretty simple, it just looks long because of all the Argument Validation...&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;public interface IRepository&amp;lt;E&amp;gt;
{
    IQueryable&amp;lt;E&amp;gt; All();
    IQueryable&amp;lt;E&amp;gt; All(string includes);
    void Add(E entity);
    void Remove(E entity);
    void Update(E entity);
    void Save();
}

public class Repository&amp;lt;E&amp;gt; : IRepository&amp;lt;E&amp;gt; where E : EntityObject
{
    protected readonly ObjectContext context;
    protected readonly ObjectSet&amp;lt;E&amp;gt; objectSet;

    public Repository(ObjectContext context)
    {
        #region Argument Validation

        if (context == null)
        {
            throw new ArgumentNullException("context");
        }

        #endregion

        this.context = context;
        this.objectSet = context.CreateObjectSet&amp;lt;E&amp;gt;();
    }

    public virtual IQueryable&amp;lt;E&amp;gt; All()
    {
        return objectSet;
    }

    public virtual IQueryable&amp;lt;E&amp;gt; All(string includes)
    {
        ObjectQuery&amp;lt;E&amp;gt; value = objectSet;
        if (String.IsNullOrEmpty(includes))
        {
            foreach (var includeProperty in includes.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
            {
                value = value.Include(includeProperty.Trim());
            }
        }
        return value;
    }

    public virtual void Add(E entity)
    {
        #region Argument Validation

        if (entity == null)
        {
            throw new ArgumentNullException("entity");
        }

        #endregion

        objectSet.AddObject(entity);
    }

    public virtual void Remove(E entity)
    {
        #region Argument Validation

        if (entity == null)
        {
            throw new ArgumentNullException("entity");
        }

        #endregion

        if (entity.EntityState == EntityState.Detached)
        {
            objectSet.Attach(entity);
        }

        objectSet.DeleteObject(entity);
    }

    public void Save()
    {
        context.SaveChanges();
    }
}

&lt;/pre&gt;
&lt;h2&gt;Unit Testing&lt;/h2&gt;
&lt;p&gt;Being able to write Unit Tests is a must and was one of the main goals of creating this repository. With this class, writing unit tests has become much more simple by creating a MemoryRepository.&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;public class MemoryRepository&amp;lt;E&amp;gt; : IRepository&amp;lt;E&amp;gt; where E : EntityObject
{
    protected readonly List&amp;lt;E&amp;gt; objectSet = new List&amp;lt;E&amp;gt;();

    public virtual IQueryable&amp;lt;E&amp;gt; All()
    {
        return objectSet.AsQueryable();
    }

    public IQueryable&amp;lt;E&amp;gt; All(string includes)
    {
        return All();
    }

    public virtual void Add(E entity)
    {
        objectSet.Add(entity);
    }

    public virtual void Remove(E entity)
    {
        objectSet.Remove(entity);
    }

    public virtual void Update(E entity)
    {
    }

    public void Save()
    {
    }
}

&lt;/pre&gt;
&lt;p&gt;Here's an example test that shows how to populate the MemoryRepository.&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;[TestMethod]
public void MemoryRepository_can_Add_entities()
{
    // Arrange
    IRepository&amp;lt;Category&amp;gt; value = new MemoryRepository&amp;lt;Category&amp;gt;();
    value.Add(new Category { Category_ID = 1, Category_Name = "Beverages" });
    value.Add(new Category { Category_ID = 2, Category_Name = "Condiments" });
    value.Add(new Category { Category_ID = 3, Category_Name = "Confections" });

    // Act
    int result = value.All().Count();

    // Assert
    Assert.AreEqual(3, result);
}
&lt;/pre&gt;
&lt;p&gt;Be sure to check out &lt;a href="http://joel.net/repository-and-unit-of-work-for-entity-framework-ef4-for-unit-testing"&gt;Part 2: Repository and Unit of Work for Entity Framework (EF4) for Unit Testing&lt;/a&gt;&lt;/p&gt;</description><pubDate>Tue, 31 Jan 2012 00:13:48 GMT</pubDate><guid isPermaLink="true">http://www.joel.net:80/generic-iqueryable-repository-for-ado.net</guid></item><item><title>Repository and Unit of Work for Entity Framework (EF4) for Unit Testing</title><link>http://www.joel.net:80/repository-and-unit-of-work-for-entity-framework-ef4-for-unit-testing</link><description>&lt;p&gt;If you are not familiar with the Unit of Work pattern you should firt look at &lt;a href="http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-the-repository-and-unit-of-work-patterns-in-an-asp-net-mvc-application"&gt;Implementing the Repository and Unit of Work Patterns in an ASP.NET MVC Application (9 of 10)&lt;/a&gt;. &amp;nbsp;It's a great article that demonstrates what the Unit of Work pattern can do.&lt;/p&gt;
&lt;p&gt;Unfortunately, that article uses a different version of Entity Framework. &amp;nbsp;I am using the default tools that come with Visual Studio and didn't want to modify the project too greatly so for me, the code wasn't usable. &amp;nbsp;I also wanted to expose the IQueryable interface which as a side effect also simplified my Repository design.&lt;/p&gt;
&lt;p&gt;By using a Repository Pattern you'll find unit testing is now possible and quite easy to write. &amp;nbsp;This illustration&amp;nbsp;(taken from&amp;nbsp;&lt;a href="http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-the-repository-and-unit-of-work-patterns-in-an-asp-net-mvc-application"&gt;asp.net&lt;/a&gt;) shows the differences between No Repository and the Repository Pattern. &amp;nbsp;Notice how there are no Unit Tests in the No Repository section also note the "Alternative Persistence Medium" node (this is where our MemoryRepository comes in).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://i1.asp.net/umbraco-beta-media/2578149/Windows-Live-Writer_8c4963ba1fa3_CE3B_Repository_pattern_diagram_1df790d3-bdf2-4c11-9098-946ddd9cd884.png" /&gt;&lt;/p&gt;
&lt;h2&gt;The Unit of Work&lt;/h2&gt;
&lt;p&gt;The job of the Unit of Work class is to manage the lifecycle and context of your Repositories. &amp;nbsp;The class is pretty simple to create, implement IDisposable, add all your Repositories and give it a Save method.&lt;/p&gt;
&lt;p&gt;This is what Northwind's Interface and Unit of Work class looks like:&lt;/p&gt;
&lt;p&gt;(for the Repository code, check out my previous post:&amp;nbsp;&lt;a href="http://joel.net/generic-iqueryable-repository-for-ado.net"&gt;Generic IQueryable Repository for Entity Framework 4&lt;/a&gt;)&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;public interface INorthwindUnitOfWork : IDisposable
{
	IRepository&amp;lt;Category&amp;gt; CategoryRepository { get; }
	IRepository&amp;lt;Customer&amp;gt; CustomerRepository { get; }
	IRepository&amp;lt;Employee&amp;gt; EmployeeRepository { get; }
	IRepository&amp;lt;Order&amp;gt; OrderRepository { get; }
	IRepository&amp;lt;Order_Detail&amp;gt; Order_DetailRepository { get; }
	IRepository&amp;lt;Product&amp;gt; ProductRepository { get; }
	IRepository&amp;lt;Shipper&amp;gt; ShipperRepository { get; }
	IRepository&amp;lt;Supplier&amp;gt; SupplierRepository { get; }
        void Save();
}

public partial class NorthwindUnitOfWork : INorthwindUnitOfWork
{
	private readonly NorthwindDataContext _context;
	private readonly IRepository&amp;lt;Category&amp;gt; _categoryRepository;
	private readonly IRepository&amp;lt;Customer&amp;gt; _customerRepository;
	private readonly IRepository&amp;lt;Employee&amp;gt; _employeeRepository;
	private readonly IRepository&amp;lt;Order&amp;gt; _orderRepository;
	private readonly IRepository&amp;lt;Order_Detail&amp;gt; _order_DetailRepository;
	private readonly IRepository&amp;lt;Product&amp;gt; _productRepository;
	private readonly IRepository&amp;lt;Shipper&amp;gt; _shipperRepository;
	private readonly IRepository&amp;lt;Supplier&amp;gt; _supplierRepository;

	public IRepository&amp;lt;Category&amp;gt; CategoryRepository
	{
		get { return _categoryRepository; }
	}

	public IRepository&amp;lt;Customer&amp;gt; CustomerRepository
	{
		get { return _customerRepository; }
	}

	public IRepository&amp;lt;Employee&amp;gt; EmployeeRepository
	{
		get { return _employeeRepository; }
	}

	public IRepository&amp;lt;Order&amp;gt; OrderRepository
	{
		get { return _orderRepository; }
	}

	public IRepository&amp;lt;Order_Detail&amp;gt; Order_DetailRepository
	{
		get { return _order_DetailRepository; }
	}

	public IRepository&amp;lt;Product&amp;gt; ProductRepository
	{
		get { return _productRepository; }
	}

	public IRepository&amp;lt;Shipper&amp;gt; ShipperRepository
	{
		get { return _shipperRepository; }
	}

	public IRepository&amp;lt;Supplier&amp;gt; SupplierRepository
	{
		get { return _supplierRepository; }
	}

	public NorthwindUnitOfWork(NorthwindDataContext context)
	{
		_context = context;

		_categoryRepository = new EntityRepository&amp;lt;Category&amp;gt;(_context);
		_customerRepository = new EntityRepository&amp;lt;Customer&amp;gt;(_context);
		_employeeRepository = new EntityRepository&amp;lt;Employee&amp;gt;(_context);
		_orderRepository = new EntityRepository&amp;lt;Order&amp;gt;(_context);
		_order_DetailRepository = new EntityRepository&amp;lt;Order_Detail&amp;gt;(_context);
		_productRepository = new EntityRepository&amp;lt;Product&amp;gt;(_context);
		_shipperRepository = new EntityRepository&amp;lt;Shipper&amp;gt;(_context);
		_supplierRepository = new EntityRepository&amp;lt;Supplier&amp;gt;(_context);
	}

	public void Save()
	{
		_context.SaveChanges();
	}

	#region IDisposable Methods

	private bool disposed = false;

	protected virtual void Dispose(bool disposing)
	{
		if (!this.disposed)
		{
			if (disposing)
			{
				_context.Dispose();
			}
		}
		this.disposed = true;
	}

	public void Dispose()
	{
		Dispose(true);
		GC.SuppressFinalize(this);
	}

	#endregion
}

&lt;/pre&gt;
&lt;h2&gt;Unit Testing&lt;/h2&gt;
&lt;p&gt;(In this example I'm using &lt;a href="http://code.google.com/p/moq/"&gt;Moq&lt;/a&gt; as my Mocking Framework)&lt;/p&gt;
&lt;p&gt;I start by creating a method called GetMockCategoryRepository that creates a new MemoryRepository object and returns returns an IRepository&amp;lt;Category&amp;gt;. &amp;nbsp;This will mimic the behavior of our Category Repository with an in memory list, allowing us to test without hitting the database.&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;private IRepository&amp;lt;Category&amp;gt; GetMockCategoryRepository()
{
	var value = new MemoryRepository&amp;lt;Category&amp;gt;();
	value.Add(new Category { Category_ID = 1, Category_Name = "Beverages" });
	value.Add(new Category { Category_ID = 2, Category_Name = "Condiments" });
	value.Add(new Category { Category_ID = 3, Category_Name = "Confections" });
	return value;
}
&lt;/pre&gt;
&lt;p&gt;Then in my test, I create a Mock INorthwindUnitOfWork, setup the CategoryRepository method to return my MemoryRepository and initialize a new NorthwindService object. For the Assert, we just need to check the count of items returned from the service is the same as our Repository!&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;[TestMethod]
public void NorthwindService_GetCategories_returns_category_names()
{
	// Arrange
	var mockUnitOfWork = new Mock&amp;lt;INorthwindUnitOfWork&amp;gt;();
	var mockCategories = GetMockCategoryRepository();

	mockUnitOfWork.SetupGet(x =&amp;gt; x.CategoryRepository)
	              .Returns(mockCategories);

	var northwindService = new NorthwindService(mockUnitOfWork.Object);

	// Act
	var categories = northwindService.GetCategories();

	// Assert
	Assert.AreEqual(mockCategories.All().Count(), categories.Length);
}
&lt;/pre&gt;
&lt;p&gt;Well, that's all you need. &amp;nbsp;You are now ready to full unit test your Services, Controllers or anything else that accesses your database.&lt;/p&gt;</description><pubDate>Mon, 23 Jan 2012 05:55:50 GMT</pubDate><guid isPermaLink="true">http://www.joel.net:80/repository-and-unit-of-work-for-entity-framework-ef4-for-unit-testing</guid></item><item><title>Logging Errors with ELMAH in ASP.NET MVC 3 – Part 5 – (JavaScript)</title><link>http://www.joel.net:80/logging-errors-with-elmah-in-asp.net-mvc-3--part-5--javascript</link><description>&lt;p&gt;Now we need a way to track those pesky client side error messages. Tracking the server side errors is the easy part, but what about those browser errors that go unnoticed and unfixed?&lt;/p&gt;
&lt;h3&gt;First, create the Server Side Handler&lt;/h3&gt;
&lt;p&gt;To handle and log JavaScript errors, we'll first need to setup some server side code. The client (browser) will pass these errors to the server, which will hand them off to ELMAH for tracking. So let's start by creating a new Exception type for our JavaScript exceptions. This will allow us to differentiate the server errors from the JavaScript errors more easily. It doesn't need much so this should be fine...&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;public class JavaScriptException : Exception
{
    public JavaScriptException(string message) : base(message)
    {
    }
}
&lt;/pre&gt;
&lt;p&gt;We are also going to need a Controller to receive the exception and hand it off to ELMAH.&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;public class ErrorController : Controller
{
    public void LogJavaScriptError(string message)
    {
        ErrorSignal
            .FromCurrentContext()
            .Raise(new JavaScriptException(message));
    }
}
&lt;/pre&gt;
&lt;p&gt;That's it for the server side changes. Next we need to setup the client (browser) to actually handle these errors and pass them onto the controller.&lt;/p&gt;
&lt;h3&gt;JavaScript stack trace&lt;/h3&gt;
&lt;p&gt;First we need to implement a &lt;a href="http://helephant.com/2007/05/diy-javascript-stack-trace"&gt;JavaScript Stack Trace&lt;/a&gt;. This will help us get more debugging information and context surrounding the errors. So copy and paste this stacktrace.js file to your project...&lt;/p&gt;
&lt;pre class="brush: javascript;"&gt;// FROM: http://helephant.com/2007/05/diy-javascript-stack-trace
 
function logError(ex, stack) {
    if (ex == null) return;
    if (logErrorUrl == null) {
        alert('logErrorUrl must be defined.');
        return;
    }
 
    var url = ex.fileName != null ? ex.fileName : document.location;
    if (stack == null &amp;amp;&amp;amp; ex.stack != null) stack = ex.stack;
 
    // format output
    var out = ex.message != null ? ex.name + ": " + ex.message : ex;
    out += ": at document path '" + url + "'.";
    if (stack != null) out += "\n  at " + stack.join("\n  at ");
 
    // send error message
    $.ajax({
        type: 'POST',
        url: logErrorUrl,
        data: { message: out }
    });
}
 
Function.prototype.trace = function()
{
    var trace = [];
    var current = this;
    while(current)
    {
        trace.push(current.signature());
        current = current.caller;
    }
    return trace;
}
 
Function.prototype.signature = function()
{
    var signature = {
        name: this.getName(),
        params: [],
        toString: function()
        {
            var params = this.params.length &amp;gt; 0 ?
                "'" + this.params.join("', '") + "'" : "";
            return this.name + "(" + params + ")"
        }
    };
    if (this.arguments)
    {
        for(var x=0; x &amp;lt; this.arguments.length; x++)
            signature.params.push(this.arguments[x]);
    }
    return signature;
}
 
Function.prototype.getName = function()
{
    if (this.name)
        return this.name;
    var definition = this.toString().split("\n")[0];
    var exp = /^function ([^\s(]+).+/;
    if (exp.test(definition))
        return definition.split("\n")[0].replace(exp, "$1") || "anonymous";
    return "anonymous";
}

window.onerror = function (msg, url, line) {
    if (arguments != null &amp;amp;&amp;amp; arguments.callee != null &amp;amp;&amp;amp; arguments.callee.trace)
        logError(msg, arguments.callee.trace());
}
&lt;/pre&gt;
&lt;h3&gt;Finally, add the Client Side Handlers&lt;/h3&gt;
&lt;p&gt;Now we need add a reference the script in the template file and also initialize the JavaScript variable 'logErrorUrl' so errorhandler.js knows where to post the error details to.&lt;/p&gt;
&lt;pre class="brush: html;"&gt;&amp;lt;script type="text/javascript"&amp;gt;
  var logErrorUrl = '@Url.Action("LogJavaScriptError", "Error")';
&amp;lt;/script&amp;gt;
&amp;lt;script src="@Url.Content("~/Scripts/errorhandler.js")" type="text/javascript"&amp;gt;&amp;lt;/script&amp;gt;
&lt;/pre&gt;
&lt;p&gt;That should be everything. All JavaScript errors should now be tracked via ELMAH.&lt;/p&gt;
&lt;h3&gt;Testing the Error Handler&lt;/h3&gt;
&lt;p&gt;If you want to test this, just to make sure it all works (which of course you do), then you can use this code to run some tests...&lt;/p&gt;
&lt;pre class="brush: html;"&gt;&amp;lt;script type="text/javascript"&amp;gt;
  function getPropertyData(value) {
    var x = value.property["data"];
  }

  function testCapturedError() {
    var x = getPropertyDataCaptured(null);
  }

  function getPropertyDataCaptured(value) {
    try {
      var x = value.property["data"];
    } catch (err) {
      if (arguments != null &amp;amp;&amp;amp; arguments.callee != null &amp;amp;&amp;amp; arguments.callee.trace)
          logError(err, arguments.callee.trace());
    }
  }
&amp;lt;/script&amp;gt;

&amp;lt;ul&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;a href="javascript:getPropertyData(null);"&amp;gt;execute getPropertyData(null) method.&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;a href="javascript:testCapturedError();"&amp;gt;execute testCapturedError() method.&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;

&lt;/pre&gt;
&lt;p&gt;This page contains two exception tests. The first test will execute an unhandled exception. The second test will demonstrate a captured error (which you should always be doing) and stack trace and log it to ELMAH. Now when you check your ELMAH page, you should see the JavaScript exceptions show up like this...&lt;/p&gt;
&lt;p&gt;&lt;img src="/Media/Default/BlogPost/blog/elmah.jpg" alt="Elmah JavaScript Error" width="630" height="380" /&gt;&lt;/p&gt;
&lt;h2&gt;Download the full project:&lt;/h2&gt;
&lt;p&gt;&lt;a href="/Media/Default/BlogPost/blog/ElmahAndMvc3.zip"&gt;ElmahAndMvc3.zip&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;This Post is Part of a Multi-Part Series&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="/logging-errors-with-elmah-in-asp.net-mvc-3--part-1--setup"&gt;Part 1 &amp;ndash; (Setup)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/logging-errors-with-elmah-in-asp.net-mvc-3--part-2--notifications"&gt;Part 2 &amp;ndash; (Notifications)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/logging-errors-with-elmah-in-asp.net-mvc-3--part-3--filtering"&gt;Part 3 &amp;ndash; (Filtering)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/logging-errors-with-elmah-in-asp.net-mvc-3--part-4--handleerrorattribute"&gt;Part 4 &amp;ndash; (HandleErrorAttribute)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/logging-errors-with-elmah-in-asp.net-mvc-3--part-5--javascript"&gt;Part 5 &amp;ndash; (JavaScript)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description><pubDate>Sat, 21 Jan 2012 06:27:41 GMT</pubDate><guid isPermaLink="true">http://www.joel.net:80/logging-errors-with-elmah-in-asp.net-mvc-3--part-5--javascript</guid></item><item><title>Setting up Visual Studio 2010 and IIS Express</title><link>http://www.joel.net:80/setting-up-visual-studio-2010-and-iis-express</link><description>&lt;h2&gt;Why use IIS Express over the Visual Studio Development Server (Cassini)?&lt;/h2&gt;
&lt;p&gt;I've seen Cassini run inconsistently on different machines, which resulted in the developers having to setup IIS on their local machines which also didn't end up working because they weren't all running the same OS.&lt;/p&gt;
&lt;p&gt;Cassini doesn't support the &amp;lt;system.webServer /&amp;gt; node in your config file, which can also give inconsistent results when deployed.&lt;/p&gt;
&lt;p&gt;Here are the reasons Scott Guthrie gives:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;It&amp;rsquo;s lightweight and easy to install (less than 10Mb download and a super quick install)&lt;/li&gt;
&lt;li&gt;It&amp;nbsp;&lt;span style="text-decoration: underline;"&gt;does not&lt;/span&gt;&amp;nbsp;require an administrator account to run/debug applications from Visual Studio&lt;/li&gt;
&lt;li&gt;It enables a&amp;nbsp;&lt;span style="text-decoration: underline;"&gt;full web-server feature set&lt;/span&gt;&amp;nbsp;&amp;ndash; including SSL, URL Rewrite, Media Support, and all other IIS 7.x modules&lt;/li&gt;
&lt;li&gt;It supports and enables the same extensibility model and web.config file settings that IIS 7.x support&lt;/li&gt;
&lt;li&gt;It can be installed side-by-side with the full IIS web server as well as the ASP.NET Development Server (they do not conflict at all)&lt;/li&gt;
&lt;li&gt;It works on Windows XP and higher operating systems &amp;ndash; giving you a full IIS 7.x developer feature-set on all OS platforms&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;more from Guthrie: &lt;a href="http://weblogs.asp.net/scottgu/archive/2010/06/28/introducing-iis-express.aspx"&gt;http://weblogs.asp.net/scottgu/archive/2010/06/28/introducing-iis-express.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h2&gt;Installation&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Be sure you have &lt;a href="http://www.microsoft.com/download/en/details.aspx?id=23691"&gt;Microsoft Visual Studio 2010 Service Pack 1&lt;/a&gt; installed.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.microsoft.com/web/gallery/install.aspx?appid=iisexpress"&gt;Download IIS Exress&lt;/a&gt; from Microsoft's Web Gallery.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Enabling IIS Express in your Web Application&lt;/h2&gt;
&lt;p&gt;Right click on your Web Application and select Use IIS Express...&lt;/p&gt;
&lt;p&gt;&lt;img src="/Media/Default/BlogPost/blog/setting-up-visual-studio-2010-and-iis-express/iis-express-menu.gif" alt="" width="543" height="265" /&gt;&lt;/p&gt;
&lt;p&gt;When you run the Web Application you should now see the IIS Express tray icon.&lt;/p&gt;
&lt;p&gt;&lt;img src="/Media/Default/BlogPost/blog/setting-up-visual-studio-2010-and-iis-express/iis-express-tray.jpg" alt="" width="207" height="61" /&gt;&lt;/p&gt;
&lt;h2&gt;Extra Credit&lt;/h2&gt;
&lt;p&gt;By default, IIS Express will bind to the localhost host name. &amp;nbsp;For most people this is not a big deal, but if you to make this accessible to other computers on the network, you'll have to add a second host name binding.&lt;/p&gt;
&lt;p&gt;I run a few Virtual Machines on my box that have older browser version (ie6, etc.) and this is how I gain access with them.&lt;/p&gt;
&lt;p&gt;To do this, right click on the tray icon and select Show All Applications and click the application you just created.&lt;/p&gt;
&lt;p&gt;&lt;img src="/Media/Default/BlogPost/blog/setting-up-visual-studio-2010-and-iis-express/iis-express-running.gif" alt="" width="480" height="390" /&gt;&lt;/p&gt;
&lt;p&gt;After clicking on the Config link (opens the applicationhost.config in Visual Studio) scroll down to the &amp;lt;sites /&amp;gt; section. &amp;nbsp;You'll see a node that looks like this:&lt;/p&gt;
&lt;pre class="brush: xml;"&gt;&amp;lt;site name="MvcApplication1" id="2"&amp;gt;
    &amp;lt;application path="/" applicationPool="Clr4IntegratedAppPool"&amp;gt;
        &amp;lt;virtualDirectory path="/" physicalPath="C:\DEV\MvcApplication1\MvcApplication1" /&amp;gt;
    &amp;lt;/application&amp;gt;
    &amp;lt;bindings&amp;gt;
      &amp;lt;binding protocol="http" bindingInformation="*:5791:localhost" /&amp;gt;
    &amp;lt;/bindings&amp;gt;
&amp;lt;/site&amp;gt;
&lt;/pre&gt;
&lt;p&gt;Add a binding for your computer's name. &amp;nbsp;In my case my computer is mobile5.&lt;/p&gt;
&lt;pre class="brush: xml;"&gt;&amp;lt;site name="MvcApplication1" id="2"&amp;gt;
    &amp;lt;application path="/" applicationPool="Clr4IntegratedAppPool"&amp;gt;
        &amp;lt;virtualDirectory path="/" physicalPath="C:\DEV\MvcApplication1\MvcApplication1" /&amp;gt;
    &amp;lt;/application&amp;gt;
    &amp;lt;bindings&amp;gt;
      &amp;lt;binding protocol="http" bindingInformation="*:5791:localhost" /&amp;gt;
      &amp;lt;binding protocol="http" bindingInformation="*:5791:mobile5" /&amp;gt;
    &amp;lt;/bindings&amp;gt;
&amp;lt;/site&amp;gt;
&lt;/pre&gt;
&lt;p&gt;Optional*: Open your project's properties and set your Start URL to&amp;nbsp;http://mobile5:5791. &amp;nbsp;Check the box "Override application root URL" and insert the same value&amp;nbsp;http://mobile5:5791/&lt;/p&gt;
&lt;p&gt;(if IIS Express is currently running you will have to stop it for the changes to take effect)&lt;/p&gt;
&lt;h2&gt;Final Thoughts&lt;/h2&gt;
&lt;p&gt;That should be it. &amp;nbsp;You should now be running your Web Application under IIS Express. &amp;nbsp;Other PCs or VMs should be able to view your projects via the additional binding.&lt;/p&gt;
&lt;p&gt;* Skip the optional step if the project is used by multiple developers or opened on multiple machines.&lt;/p&gt;
&lt;p&gt;** Additional bindings may require you to run Visual Studio as an Administrator or add entries into your host files.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;</description><pubDate>Wed, 14 Sep 2011 19:29:08 GMT</pubDate><guid isPermaLink="true">http://www.joel.net:80/setting-up-visual-studio-2010-and-iis-express</guid></item><item><title>Data, Context and Interaction (DCI) &amp; Windows Workflow (C#)</title><link>http://www.joel.net:80/data-context-and-interaction-dci-windows-workflow-csharp</link><description>&lt;p&gt;&lt;b&gt;Disclaimer:&lt;/b&gt; This article assumes you already know the following: C#, WF4 and Extension Methods.&lt;/p&gt;
&lt;p&gt;Lately I have been reading a bunch about Data, Context and Interaction (DCI) and a lot of my current project have involved using&amp;nbsp;Windows Workflow Foundation (WF4). &amp;nbsp;Recently I've come to the realizaion that a WF4 Activity can also be the perfect DCI context because both are basically use cases.&lt;/p&gt;
&lt;p&gt;I've taken some &lt;a href="http://horsdal.blogspot.com/2009/05/dci-in-c.html"&gt;sample code&lt;/a&gt; written by Christian Horsdal about DCI in C# and applied to to a Workflow. &amp;nbsp;He's has &lt;a href="http://horsdal.blogspot.com/search/label/DCI"&gt;some very good posts&lt;/a&gt; about DCI and C#, I'd recommend checking them out if you want to learn more.&lt;/p&gt;
&lt;h2&gt;The Data&lt;/h2&gt;
&lt;p&gt;First we'll have a look at the data models we'll be using.&lt;/p&gt;
&lt;p&gt;We've got our base Account class and our derived classes CheckingAccount and SavingsAccount.&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;public abstract class Account
{
    public double Balance { get; protected set; }

    public void Withdraw(double amount)
    {
        Balance -= amount;
    }

    public void Deposit(double amount)
    {
        Balance += amount;
    }

    public void Log(string message)
    {
        Console.WriteLine("Log: {0}", message);
    }
}
&lt;/pre&gt;
&lt;pre class="brush: csharp;"&gt;public class CheckingAccount
    : Account, TransferMoneySource, TransferMoneySink
{
    public CheckingAccount()
    {
        Balance = 1000;
    }

    public override string ToString()
    {
        return "Balance " + Balance;
    }
}
&lt;/pre&gt;
&lt;pre class="brush: csharp;"&gt;public class SavingsAccount
    : Account, TransferMoneySource, TransferMoneySink
{
    public SavingsAccount()
    {
        Balance = 1000;
    }

    public override string ToString()
    {
        return "Balance " + Balance;
    }
}
&lt;/pre&gt;
&lt;h2&gt;The Interaction&lt;/h2&gt;
&lt;p&gt;In our Data Models, you'll notice there's a TransferMoneySource and TransferMoneySink on each of our derived account classes. Those are the Roles these accounts can play, they can be both the Source or Sink when transfering money.&lt;/p&gt;
&lt;p&gt;The Roles are defined as Interfaces and provide just the minimum amount of data to perform that Interaction.&lt;/p&gt;
&lt;p&gt;In C# one way of providing the DCI Interaction is through the use of &lt;a href="http://msdn.microsoft.com/en-us/library/bb383977.aspx"&gt;extension methods&lt;/a&gt; (eg: the TransferTo method below).&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;public interface TransferMoneySink
{
    void Deposit(double amount);
    void Log(string message);
}

public interface TransferMoneySource
{
    double Balance { get; }
    void Withdraw(double amount);
    void Log(string message);
}

public static class TransferMoneySourceTrait
{
    public static void TransferTo(this TransferMoneySource self, TransferMoneySink recipient, double amount)
    {
        if (self.Balance &amp;lt; 0)
        {
            throw new ApplicationException("insufficient funds");
        }

        self.Withdraw(amount);
        self.Log("Withdrawing " + amount);
        recipient.Deposit(amount);
        recipient.Log("Depositing " + amount);
    }
}
&lt;/pre&gt;
&lt;h2&gt;The Context&lt;/h2&gt;
&lt;p&gt;For the Transfer Money use case, we're going to Withdraw money from one account and Deposit it into another using the TransferTo extension method we created above. This use case requires three things: the Source, the Sink and the Amount.&lt;/p&gt;
&lt;p&gt;Written as a WF4 Activity, it will look like this...&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;public sealed class TransferMoneyActivity : CodeActivity
{
    [RequiredArgument]
    public InArgument&amp;lt;TransferMoneySource&amp;gt; Source { get; set; }

    [RequiredArgument]
    public InArgument&amp;lt;TransferMoneySink&amp;gt; Sink { get; set; }

    [RequiredArgument]
    public InArgument&amp;lt;double&amp;gt; Amount { get; set; }

    protected override void Execute(CodeActivityContext context)
    {
        var source = Source.Get(context);
        var sink = Sink.Get(context);
        var amount = Amount.Get(context);

        source.TransferTo(sink, amount);
    }
}
&lt;/pre&gt;
&lt;h2&gt;Executing the Activity / Context (use case)&lt;/h2&gt;
&lt;p&gt;Transfering $100 from the CheckingAccount to SavingsAccount can be as simple as this.&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;var savingsAccount = new SavingsAccount();
var checkingAccount = new CheckingAccount();

var arguments = new Dictionary&amp;lt;string, object&amp;gt; {
    { "Source", checkingAccount },
    { "Sink", savingsAccount },
    { "Amount", 100 }
};

WorkflowInvoker.Invoke(new DemoActivity(), arguments);
&lt;/pre&gt;
&lt;p&gt;And now that our Context is a standard WF4 Activity, we can easily incorporate it into our larger Workflows.&lt;/p&gt;
&lt;p&gt;&lt;img src="/Media/Default/BlogPost/blog/data-context-and-interaction-dci-windows-workflow-csharp/TransferMoneyActivity.gif" alt="" width="274" height="456" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="/Media/Default/BlogPost/blog/data-context-and-interaction-dci-windows-workflow-csharp/DCI-and-Workflow.zip"&gt;Download the sample project here&lt;/a&gt;&lt;/p&gt;</description><pubDate>Wed, 17 Aug 2011 23:25:45 GMT</pubDate><guid isPermaLink="true">http://www.joel.net:80/data-context-and-interaction-dci-windows-workflow-csharp</guid></item><item><title>Logging Errors with ELMAH in ASP.NET MVC 3 – Part 4 - (HandleErrorAttribute)</title><link>http://www.joel.net:80/logging-errors-with-elmah-in-asp.net-mvc-3--part-4--handleerrorattribute</link><description>&lt;h3&gt;Creating a custom HandleErrorAttribute for ELMAH (Optional)&lt;/h3&gt;
&lt;p&gt;Remember when &lt;a href="/logging-errors-with-elmah-in-asp.net-mvc-3--part-1--setup"&gt;we commented out that line&lt;/a&gt; from our Global.asax.cs in Part 1? Well, building our own HandleErrorAttribute will allow us to put it back or more importantly prevent the HandleErrorAttribute from overriding our ELMAH behavior. Currently the HandleError attribute will prevent any errors from bubbling up to ELMAH and we can't guarantee down the line, someone won't use a HandleError attribute like this...&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;[HandleError]
public class MyClass
{
    // This error won't be handled by ELMAH
    public MyMethod() {
        throw new Exception("oops");
    }
}
&lt;/pre&gt;
&lt;p&gt;The &lt;a href="http://stackoverflow.com/questions/766610/how-to-get-elmah-to-work-with-asp-net-mvc-handleerror-attribute/779961#779961"&gt;solution to this problem&lt;/a&gt;&amp;nbsp;is to implement our own custom HandleErrorAttribute. Add the following class to your project...&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;using System;
using System.Web;
using System.Web.Mvc;
using Elmah;

namespace ElmahAndMvc3
{
    public class ElmahHandleErrorAttribute : System.Web.Mvc.HandleErrorAttribute
    {
        public override void OnException(ExceptionContext context)
        {
            base.OnException(context);

            var e = context.Exception;
            if (!context.ExceptionHandled   // if unhandled, will be logged anyhow
                || RaiseErrorSignal(e)      // prefer signaling, if possible
                || IsFiltered(context))     // filtered?
                return;

            LogException(e);
        }

        private static bool RaiseErrorSignal(Exception e)
        {
            var context = HttpContext.Current;
            if (context == null)
                return false;
            var signal = ErrorSignal.FromContext(context);
            if (signal == null)
                return false;
            signal.Raise(e, context);
            return true;
        }

        private static bool IsFiltered(ExceptionContext context)
        {
            var config = context.HttpContext.GetSection("elmah/errorFilter")
                         as ErrorFilterConfiguration;

            if (config == null)
                return false;

            var testContext = new ErrorFilterModule.AssertionHelperContext(
                                      context.Exception, HttpContext.Current);

            return config.Assertion.Test(testContext);
        }

        private static void LogException(Exception e)
        {
            var context = HttpContext.Current;
            ErrorLog.GetDefault(context).Log(new Error(e, context));
        }
    }
}
&lt;/pre&gt;
&lt;p&gt;And modify the RegisterGlobalFilters in your Global.asax.cs...&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
    filters.Add(new ElmahHandleErrorAttribute());
}
&lt;/pre&gt;
&lt;p&gt;Now you have no worries about [HandleError] intercepting errors on your site.&lt;/p&gt;
&lt;p&gt;Next Step: &lt;a href="/logging-errors-with-elmah-in-asp.net-mvc-3--part-5--javascript"&gt;Logging Errors with ELMAH in ASP.NET MVC 3 &amp;ndash; Part 5 &amp;ndash; (JavaScript) &amp;raquo;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;This Post is Part of a Multi-Part Series&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="/logging-errors-with-elmah-in-asp.net-mvc-3--part-1--setup"&gt;Part 1 &amp;ndash; (Setup)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/logging-errors-with-elmah-in-asp.net-mvc-3--part-2--notifications"&gt;Part 2 &amp;ndash; (Notifications)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/logging-errors-with-elmah-in-asp.net-mvc-3--part-3--filtering"&gt;Part 3 &amp;ndash; (Filtering)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/logging-errors-with-elmah-in-asp.net-mvc-3--part-4--handleerrorattribute"&gt;Part 4 &amp;ndash; (HandleErrorAttribute)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/logging-errors-with-elmah-in-asp.net-mvc-3--part-5--javascript"&gt;Part 5 &amp;ndash; (JavaScript)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description><pubDate>Tue, 19 Jul 2011 21:09:24 GMT</pubDate><guid isPermaLink="true">http://www.joel.net:80/logging-errors-with-elmah-in-asp.net-mvc-3--part-4--handleerrorattribute</guid></item><item><title>Logging Errors with ELMAH in ASP.NET MVC 3 – Part 3 – (Filtering)</title><link>http://www.joel.net:80/logging-errors-with-elmah-in-asp.net-mvc-3--part-3--filtering</link><description>&lt;h3&gt;Filtering Unwanted Errors&lt;/h3&gt;
&lt;p&gt;Ok, the reason I really like receiving an email for the every error message is because it will get annoying really fast. This results in me fixing the errors really fast. But there are just some errors that you just can't (or don't want to) "fix". If you noticed in Part 1, the error page contained some 404 errors for /favicon.ico. Errors like these will get annoying really quickly, and fortunately there's an easy way to filter them out. This chunk of code will filter out all 404 errors with a URL matching /favicon.ico.&lt;/p&gt;
&lt;pre class="brush: xml;"&gt;&amp;lt;system.web&amp;gt;
  &amp;lt;httpModules&amp;gt;
    &amp;lt;add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" /&amp;gt;
  &amp;lt;/httpModules&amp;gt;
&amp;lt;/system.web&amp;gt;

&amp;lt;system.webServer&amp;gt;
  &amp;lt;modules&amp;gt;
    &amp;lt;add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" /&amp;gt;
  &amp;lt;/modules&amp;gt;
&amp;lt;/system.webServer&amp;gt;

&amp;lt;elmah&amp;gt;
  &amp;lt;errorFilter&amp;gt;
    &amp;lt;test&amp;gt; &amp;lt;!-- do not log favicon.ico 404's --&amp;gt;
      &amp;lt;and&amp;gt;
        &amp;lt;equal binding="HttpStatusCode" value="404" type="Int32" /&amp;gt;
        &amp;lt;regex binding="Context.Request.ServerVariables['URL']"
               pattern="/favicon\.ico(\z|\?)" /&amp;gt;
      &amp;lt;/and&amp;gt;
    &amp;lt;/test&amp;gt;
  &amp;lt;/errorFilter&amp;gt;
&amp;lt;/elmah&amp;gt;
&lt;/pre&gt;
&lt;h3&gt;Filtering 404 errors out of the ErrorMailModule&lt;/h3&gt;
&lt;p&gt;Some errors are less important than others, for example 404 errors. I want to log all the 404's my site may receive, but I do not want an email every time someone mistypes a url on my site. To keep logging all errors (including 404's), but filter some from being sent via email, we can add this method to our Global.asax.cs file.&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;public void ErrorMail_Filtering(object sender, ExceptionFilterEventArgs e)
{
    var httpException = e.Exception as HttpException;
    if (httpException != null &amp;amp;&amp;amp; httpException.GetHttpCode() == 404)
    {
        e.Dismiss();
    }
}
&lt;/pre&gt;
&lt;p&gt;The ELMAH filtering can do a lot of cool stuff, you can even write scripts in JScript, but for the most part, the example above will be enough to do what you want. For more on filtering go to &lt;a href="http://code.google.com/p/elmah/wiki/ErrorFiltering"&gt;the wiki page&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Next Step: &lt;a href="/logging-errors-with-elmah-in-asp.net-mvc-3--part-4--handleerrorattribute"&gt;Logging Errors with ELMAH in ASP.NET MVC 3 &amp;ndash; Part 4 &amp;ndash; (HandleErrorAttribute) &amp;raquo;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h3&gt;This Post is Part of a Multi-Part Series&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="/logging-errors-with-elmah-in-asp.net-mvc-3--part-1--setup"&gt;Part 1 &amp;ndash; (Setup)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/logging-errors-with-elmah-in-asp.net-mvc-3--part-2--notifications"&gt;Part 2 &amp;ndash; (Notifications)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/logging-errors-with-elmah-in-asp.net-mvc-3--part-3--filtering"&gt;Part 3 &amp;ndash; (Filtering)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/logging-errors-with-elmah-in-asp.net-mvc-3--part-4--handleerrorattribute"&gt;Part 4 &amp;ndash; (HandleErrorAttribute)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/logging-errors-with-elmah-in-asp.net-mvc-3--part-5--javascript"&gt;Part 5 &amp;ndash; (JavaScript)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description><pubDate>Tue, 19 Jul 2011 21:09:06 GMT</pubDate><guid isPermaLink="true">http://www.joel.net:80/logging-errors-with-elmah-in-asp.net-mvc-3--part-3--filtering</guid></item><item><title>Logging Errors with ELMAH in ASP.NET MVC 3 – Part 2 – (Notifications)</title><link>http://www.joel.net:80/logging-errors-with-elmah-in-asp.net-mvc-3--part-2--notifications</link><description>&lt;h3&gt;Setup Notifications for ELMAH Errors&lt;/h3&gt;
&lt;p&gt;Now that ELMAH is setup, you need a way to be notified when an error occurs. Though you can just subscribe to your ELMAH RSS feed at /elmah.axd/rss, I prefer to receive an email notification as soon as an error happens. To do this simply merge the following changes into your web.config's &amp;lt;configuration&amp;gt; section.&lt;/p&gt;
&lt;pre class="brush: xml;"&gt;&amp;lt;system.web&amp;gt;
  &amp;lt;httpModules&amp;gt;
    &amp;lt;add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" /&amp;gt;
  &amp;lt;/httpModules&amp;gt;
&amp;lt;/system.web&amp;gt;
&amp;lt;/pre&amp;gt;

&amp;lt;system.webServer&amp;gt;
  &amp;lt;modules&amp;gt;
    &amp;lt;add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" /&amp;gt;
  &amp;lt;/modules&amp;gt;
&amp;lt;/system.webServer&amp;gt;

&amp;lt;elmah&amp;gt;
  &amp;lt;errorMail from="e@mail.address"
             to="e@mail.address"
             subject="elmah error mail" /&amp;gt;
&amp;lt;/elmah&amp;gt;
&lt;/pre&gt;
&lt;p&gt;There's a lot more configurability, but those are the basics. Here's a &lt;a href="http://dotnetslackers.com/articles/aspnet/ErrorLoggingModulesAndHandlers.aspx"&gt;good article&lt;/a&gt;&amp;nbsp;showing more options. Also if you haven't already done it, set your smtp settings too...&lt;/p&gt;
&lt;pre class="brush: xml;"&gt;&amp;lt;system.net&amp;gt;
  &amp;lt;mailSettings&amp;gt;
    &amp;lt;smtp&amp;gt;
      &amp;lt;network host="localhost" /&amp;gt;
    &amp;lt;/smtp&amp;gt;
  &amp;lt;/mailSettings&amp;gt;  
&amp;lt;/system.net&amp;gt;
&lt;/pre&gt;
&lt;p&gt;Next Step: &lt;a href="/logging-errors-with-elmah-in-asp.net-mvc-3--part-3--filtering"&gt;Logging Errors with ELMAH in ASP.NET MVC 3 &amp;ndash; Part 3 &amp;ndash; (Filtering) &amp;raquo;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;This Post is Part of a Multi-Part Series&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="/logging-errors-with-elmah-in-asp.net-mvc-3--part-1--setup"&gt;Part 1 &amp;ndash; (Setup)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/logging-errors-with-elmah-in-asp.net-mvc-3--part-2--notifications"&gt;Part 2 &amp;ndash; (Notifications)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/logging-errors-with-elmah-in-asp.net-mvc-3--part-3--filtering"&gt;Part 3 &amp;ndash; (Filtering)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/logging-errors-with-elmah-in-asp.net-mvc-3--part-4--handleerrorattribute"&gt;Part 4 &amp;ndash; (HandleErrorAttribute)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/logging-errors-with-elmah-in-asp.net-mvc-3--part-5--javascript"&gt;Part 5 &amp;ndash; (JavaScript)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description><pubDate>Tue, 19 Jul 2011 21:08:35 GMT</pubDate><guid isPermaLink="true">http://www.joel.net:80/logging-errors-with-elmah-in-asp.net-mvc-3--part-2--notifications</guid></item><item><title>Getting ASP.NET MVC 3 working on DiscountASP.net</title><link>http://www.joel.net:80/getting-asp.net-mvc-3-working-on-discountasp.net</link><description>&lt;p&gt;Though this article should apply to any IIS7 shared-hosting platform, I can only confirm it works on &lt;a href="http://discountasp.net"&gt;DiscountASP.net&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;Getting Errors After Deploying your Application?&lt;/h3&gt;
&lt;p&gt;After deploying your application, you might see the following error message...&lt;/p&gt;
&lt;p&gt;&lt;strong style="color: red;"&gt;Could not load file or assembly 'System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong style="color: red;"&gt;&lt;/strong&gt;This is due to the MVC binaries not being installed in the GAC on the server. But do not fret, the GAC is only optional for MVC 3!&lt;/p&gt;
&lt;h3&gt;Adding References to the Assemblies&lt;/h3&gt;
&lt;p&gt;&lt;img src="/Media/Default/BlogPost/blog/mvc3-references.jpg" alt="MVC 3 References" width="287" height="580" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://joel.net/wordpress/wp-content/uploads/2011/02/mvc3-references.jpg"&gt;&lt;/a&gt;Add references to all of the following ASP.NET MVC 3 Assemblies.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Microsoft.Web.Infrastructure&lt;/li&gt;
&lt;li&gt;System.Web.Abstractions&lt;/li&gt;
&lt;li&gt;System.Web.Helpers&lt;/li&gt;
&lt;li&gt;System.Web.Mvc&lt;/li&gt;
&lt;li&gt;System.Web.Razor&lt;/li&gt;
&lt;li&gt;System.Web.WebPages&lt;/li&gt;
&lt;li&gt;System.Web.WebPages.Deployment&lt;/li&gt;
&lt;li&gt;System.Web.WebPages.Razor&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src="/Media/Default/BlogPost/blog/mvc3-references.jpg" alt="MVC 3 Copy Local" width="287" height="580" /&gt;&lt;/p&gt;
&lt;div style="clear: both;"&gt;&lt;br /&gt; Finally set them all to Copy Local = True. Now when you deploy all the required MVC libraries will be included.&lt;/div&gt;
&lt;p&gt;&lt;br /&gt; EDIT: You can also use &lt;a href="http://blog.discountasp.net/getting-asp-net-mvc-3-working-on-discountasp-net"&gt;Deployable Dependencies&lt;/a&gt;.&lt;/p&gt;</description><pubDate>Tue, 19 Jul 2011 07:57:35 GMT</pubDate><guid isPermaLink="true">http://www.joel.net:80/getting-asp.net-mvc-3-working-on-discountasp.net</guid></item><item><title>Logging Errors with ELMAH in ASP.NET MVC 3 – Part 1 – (Setup)</title><link>http://www.joel.net:80/logging-errors-with-elmah-in-asp.net-mvc-3--part-1--setup</link><description>&lt;h3&gt;Add the ELMAH binary to the project&lt;/h3&gt;
&lt;p&gt;To install ELMAH using NuGet In Visual Studio 2010 (recommended), go to Tools &amp;gt;&amp;gt; Library Package Manager &amp;gt;&amp;gt; Add Library Package Reference&amp;hellip; Select Online from the left search for Elmah and click Install.&lt;/p&gt;
&lt;p&gt;Alternatively you can, &lt;a href="http://code.google.com/p/elmah"&gt;download ELMAH from here&lt;/a&gt; and add a reference to the Elmah library.&lt;/p&gt;
&lt;h3&gt;Configure the ELMAH basics&lt;/h3&gt;
&lt;p&gt;Before we get all fancy, let&amp;rsquo;s just get it running. To do that, you need to merge the following changes into your web.config. NuGet should have made these additions already for you&amp;hellip; but let&amp;rsquo;s double check it just in case.&lt;/p&gt;
&lt;pre class="brush: xml;"&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;
&amp;lt;configuration&amp;gt;
 
  &amp;lt;configSections&amp;gt;
    &amp;lt;sectionGroup name="elmah"&amp;gt;
      &amp;lt;section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" /&amp;gt;
      &amp;lt;section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" /&amp;gt;
      &amp;lt;section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" /&amp;gt;
      &amp;lt;section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" /&amp;gt;
    &amp;lt;/sectionGroup&amp;gt;
  &amp;lt;/configSections&amp;gt;
 
  &amp;lt;elmah&amp;gt;
    &amp;lt;security allowRemoteAccess="yes" /&amp;gt;
  &amp;lt;/elmah&amp;gt;
 
  &amp;lt;system.web&amp;gt;
    &amp;lt;httpModules&amp;gt;
      &amp;lt;add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" /&amp;gt;
    &amp;lt;/httpModules&amp;gt;
    &amp;lt;httpHandlers&amp;gt;
      &amp;lt;add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" /&amp;gt;
    &amp;lt;/httpHandlers&amp;gt;
  &amp;lt;/system.web&amp;gt;
 
  &amp;lt;system.webServer&amp;gt;
    &amp;lt;modules&amp;gt;
      &amp;lt;add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" /&amp;gt;
    &amp;lt;/modules&amp;gt;
    &amp;lt;handlers&amp;gt;
      &amp;lt;add name="Elmah" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" /&amp;gt;
    &amp;lt;/handlers&amp;gt;
  &amp;lt;/system.webServer&amp;gt;
 
&amp;lt;/configuration&amp;gt;

&lt;/pre&gt;
&lt;p&gt;Also comment out this line from your Global.asax file as it interferes with ELMAH.&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
    //filters.Add(new HandleErrorAttribute());
}
&lt;/pre&gt;
&lt;p&gt;Note: The HandleErrorAttribute captures any unhandled errors and displays the Error view when custom errors are turned on. We&amp;rsquo;ll re-enable this later in this series when we further extend ELMAH, but for now, just comment it out.&lt;/p&gt;
&lt;h3&gt;Verify ELMAH is setup&lt;/h3&gt;
&lt;p&gt;You should now be able to run your project, go to /elmah.axd and see a report similar to this one...&lt;/p&gt;
&lt;p&gt;&lt;img src="/Media/Default/BlogPost/blog/elmah.jpg" alt="Elmah Default Install" width="630" height="380" /&gt;&lt;/p&gt;
&lt;p&gt;Well, that was all pretty simple. Just a little bit of &lt;a href="http://knowyourmeme.com/memes/copypasta"&gt;Copypasta&lt;/a&gt; and you&amp;rsquo;ve got the basics of ELMAH up and running. This is confirmed to work on DiscountASP.net shared hosting environment.&lt;/p&gt;
&lt;p&gt;Next Step: &lt;a href="/logging-errors-with-elmah-in-asp.net-mvc-3--part-2--notifications"&gt;Logging Errors with ELMAH in ASP.NET MVC 3 &amp;ndash; Part 2 &amp;ndash; (Notifications) &amp;raquo;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;This Post is Part of a Multi-Part Series&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="/logging-errors-with-elmah-in-asp.net-mvc-3-&amp;ndash;-part-1-&amp;ndash;-setup"&gt;Part 1 &amp;ndash; (Setup)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/logging-errors-with-elmah-in-asp.net-mvc-3--part-2--notifications"&gt;Part 2 &amp;ndash; (Notifications)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/logging-errors-with-elmah-in-asp.net-mvc-3--part-3--filtering"&gt;Part 3 &amp;ndash; (Filtering)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/logging-errors-with-elmah-in-asp.net-mvc-3--part-4--handleerrorattribute"&gt;Part 4 &amp;ndash; (HandleErrorAttribute)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/logging-errors-with-elmah-in-asp.net-mvc-3--part-5--javascript"&gt;Part 5 &amp;ndash; (JavaScript)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description><pubDate>Tue, 19 Jul 2011 07:57:33 GMT</pubDate><guid isPermaLink="true">http://www.joel.net:80/logging-errors-with-elmah-in-asp.net-mvc-3--part-1--setup</guid></item><item><title>Coercion - why we listen to what "they" say</title><link>http://www.joel.net:80/coercion---why-we-listen-to-what-they-say</link><description>&lt;p&gt;I picked up a new book,&amp;nbsp;&lt;a href="http://www.amazon.com/exec/obidos/tg/detail/-/157322829X/qid=1091020572/sr=8-1/ref=pd_ka_1/103-7466951-6859041?v=glance&amp;amp;s=books&amp;amp;n=507846"&gt;Coercion&lt;/a&gt;.&amp;nbsp; So far it's a pretty good book.&amp;nbsp; It talks about the ways the media,&amp;nbsp;sales, and retail personel&amp;nbsp;manipulate us without us being the wiser.&lt;/p&gt;
&lt;p&gt;In the section I just finished reading, a retired auto salesman is describing to the author a popular&amp;nbsp;way to&amp;nbsp;break through the buyers defenses and make them more responsive to coercion.&lt;/p&gt;
&lt;blockquote&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;As Miller explained, "Somewhere during that demo drive, while you're making your trial close -- not asking for the sale yet -- you ask him, in these exact words, 'Is this the type of vehicle you would like to own?' It happens.&amp;nbsp; And anyone will tell you this, the vacuum cleaner salesman, the carpet salesman - the customer has a split second of insanity.&amp;nbsp; The mind goes blank, the body paralyzes, the eyes get glassy, dilated.&amp;nbsp; And you'd be surprised how many people have an accident at just that moment!&amp;nbsp; Ask any car dealer.&amp;nbsp; We always joke about it."&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;How could a single question provoke such an extreme response?&amp;nbsp; Partly because it relies on disassociation.&amp;nbsp; The customer is already in a vehicle, being asked to imagine himself owning the same type of vehicle.&amp;nbsp; It's the same as if I asked you if this is the kind of book you can imagine yourself reading.&amp;nbsp; Your current situation is reframed in fantasy.&amp;nbsp; It creates a momentary confusion, or disassociation, from the activity you're involved in.&amp;nbsp; That's why so many drivers crash.&amp;nbsp; They are no longer just driving the car but imagining themselves driving the car.&amp;nbsp; It is a momtary loss of awareness, during which the customer's defense mechanisms and rational processes are disabled.&lt;/blockquote&gt;
&lt;p&gt;So far I think the book is great and would recomment it to everyone. I'll let you know more as I read on.&lt;/p&gt;</description><pubDate>Tue, 19 Jul 2011 07:57:29 GMT</pubDate><guid isPermaLink="true">http://www.joel.net:80/coercion---why-we-listen-to-what-they-say</guid></item><item><title>Akismet .Net 2.0 API (anti-comment-spam)</title><link>http://www.joel.net:80/akismet-.net-2.0-api-anti-comment-spam</link><description>&lt;p&gt;It looks like spammers are set on ruining the entire internet. Not only do I get 1000's of unwanted emails every day, but now spammers are starting to pollute blog comments.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Fortunately the guys over at &lt;a href="http://www.akismet.com/"&gt;Akismet&lt;/a&gt; have developed an anti-comment-spam web API. There are multiple &lt;a href="http://akismet.com/development/"&gt;libraries&lt;/a&gt; that have been developed for Akismet, though none for .Net. Since I am going to be implementing this on Joel.net, I figured I would just wrap it all up into an easy to use library for me and you too!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.codeplex.com/wikipage?ProjectName=AkismetApi"&gt;Download source project&lt;/a&gt;&lt;/p&gt;</description><pubDate>Tue, 19 Jul 2011 07:57:28 GMT</pubDate><guid isPermaLink="true">http://www.joel.net:80/akismet-.net-2.0-api-anti-comment-spam</guid></item><item><title>US has a 90% Chance of Economic Doom.</title><link>http://www.joel.net:80/us-has-a-90-chance-of-economic-doom</link><description>&lt;p&gt;&lt;img src="/Media/Default/BlogPost/blog/_40510857_dollar_euro1011_gra203.gif" alt="Dollar / Euro Exchange Rate" align="right" width="203" height="184" /&gt; There have been a lot of economic forecasts floating around the news lately; &lt;em&gt;very few&lt;/em&gt; of them seem to have a positive outlook on the future. Morgan Stanley's (investment banking giant) chief economist, Stephen Roach is giving us a &lt;a href="http://business.bostonherald.com/businessNews/view.bg?articleid=55356"&gt;10% chance of getting through this OK&lt;/a&gt;, citing &lt;strong&gt;our record US trade deficit being the cause&lt;/strong&gt;. &lt;br /&gt;&lt;br /&gt;From 1992 and 1997, &lt;a href="http://www.freetrade.org/pubs/pas/tpa-002.html"&gt;the US trade deficit almost tripled&lt;/a&gt;. In 2002 the US trade deficit hit a record $418 billion; only to be outdone &lt;strong&gt;in 2003 when we hit &lt;em&gt;another record&lt;/em&gt; &lt;/strong&gt;&lt;a href="http://www.cbsnews.com/stories/2004/02/13/national/main600034.shtml"&gt;&lt;strong&gt;deficit of $489.4 billion&lt;/strong&gt;.&lt;/a&gt; Thats a &lt;em&gt;17.1% increase&lt;/em&gt; in just one year. &lt;br /&gt;&lt;br /&gt;Stephen Roach argues &lt;strong&gt;the dollar will &lt;em&gt;continue to fall&lt;/em&gt; as a result of the U.S trade deficit, thus creating inflation&lt;/strong&gt;. To combat inflation, &lt;a href="http://www.reuters.com/newsArticle.jhtml?type=businessNews&amp;amp;storyID=6978489&amp;amp;src=rss/businessNews"&gt;the Federal Reserve will be forced to &lt;strong&gt;raise interest rates&lt;/strong&gt;, higher and sooner&lt;/a&gt; than we or they would&amp;nbsp;like. We've already seen the &lt;a href="http://www.cbsnews.com/stories/2004/09/21/national/main644702.shtml"&gt;Feds increase rates 4 times this year&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Unfortunately the boost to the dollar from the Fed is &lt;a href="http://www.reuters.com/newsArticle.jhtml?type=businessNews&amp;amp;storyID=7067966&amp;amp;pageNumber=1"&gt;only a short term boost&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;In-debt Americans will be hurt most by this. Since the majority of us are in debt, &lt;strong&gt;the effect will not only be nation-wide, but global&lt;/strong&gt;, effecting the non-in-debt as well. The effects of this are &lt;a href="http://news.bbc.co.uk/1/hi/business/4042451.stm"&gt;already hurting &lt;em&gt;other&lt;/em&gt; nations&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Americans are going deeper and deeper into debt, as a result &lt;em&gt;bankruptcy&amp;nbsp;is on the rise&lt;/em&gt;.&amp;nbsp; Bankruptcy law currently protects your pensions, 401(k)s, social security and a few others.&amp;nbsp;Because of this increase in bankruptcy, the&amp;nbsp;&lt;a href="http://story.news.yahoo.com/news?tmpl=story2&amp;amp;u=/ap/20041202/ap_on_go_su_co/scotus_bankruptcy"&gt;Supreme Court&amp;nbsp;is now deciding if they can seize these assets &lt;/a&gt;and how much of it to seize.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;table style="margin: 5px; width: 200px; border: darkslategray 2px dashed;" align="left" border="0"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="http://www.fool.com/ccc/secrets/secrets01.htm"&gt;&lt;strong&gt;"A long time ago, we were a nation of cash-rich, house-poor people. Then, we became house rich and cash poor. Today, we're a nation that's credit dependent and cash broke."&lt;/strong&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;a href="http://www.reuters.com/newsArticle.jhtml?type=businessNews&amp;amp;storyID=6981311&amp;amp;src=rss/businessNews"&gt;&lt;strong&gt;Mortgage rates are &lt;em&gt;now&lt;/em&gt; on the rise&lt;/strong&gt;&lt;/a&gt;. Mortgage owners with variable interest rates &lt;em&gt;will be affected greatly&lt;/em&gt;. Unfortunately close to &lt;a href="http://business.bostonherald.com/businessNews/view.bg?articleid=55356"&gt;&lt;strong&gt;half of all new mortgages have a variable interest rate&lt;/strong&gt;&lt;/a&gt;. This will cause a greater increase of foreclosures. &lt;br /&gt;&lt;br /&gt;Foreclosures have already been on the rise for some time now. In some Counties &lt;a href="http://www.larimer.org/compass/bankruptcy_ec_ind.htm"&gt;there has been a &lt;strong&gt;100%+ increase in foreclosures in 2003&lt;/strong&gt;&lt;/a&gt;, when compared to 2002. &lt;a href="http://www.inman.com/inmannews.aspx?ID=43811"&gt;Foreclosures increases have also been predicted for California and Nevada through 2005&lt;/a&gt;. &lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;table style="margin: 5px; width: 250px; border: darkslategray 2px dashed;" align="right" border="0"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="http://www.inman.com/inmannews.aspx?ID=43811"&gt;&lt;strong&gt;Lexis McGee, foreclosures.com, said her company has always seen a correlation between rising interest rates and rising levels of foreclosure activity.&lt;/strong&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;As interest rates rise, &lt;strong&gt;the prices of housing will fall&lt;/strong&gt;, causing almost half of home owners (variable rates) &lt;em&gt;payments to increase&lt;/em&gt; at the same time they'll find themselves &lt;em&gt;owing more&lt;/em&gt; than their house is worth. &lt;br /&gt;&lt;br /&gt;&lt;b&gt;Foreclosure News:&lt;/b&gt; &lt;a href="http://www.foreclosures.com/pages/News_Archive.asp"&gt;foreclosures.com&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;Housing hit an all time high in June for most communities. Though &lt;strong&gt;housing has started a decline&lt;/strong&gt; or what is being called a &lt;a href="http://www.bizjournals.com/sacramento/stories/2004/08/23/daily15.html"&gt;"cooling"&lt;/a&gt; or &lt;a href="http://www.freep.com/news/nw/bubble12_20040312.htm"&gt;"cool-down"&lt;/a&gt;. This can already be seen in &lt;a href="http://www.bizjournals.com/sacramento/stories/2004/08/23/daily15.html"&gt;California&lt;/a&gt; and &lt;a href="http://business.bostonherald.com/businessNews/view.bg?articleid=55589"&gt;Boston&lt;/a&gt;&amp;nbsp;as well as&amp;nbsp;other areas. Meanwhile Scott Van Voorhis is predicting a &lt;a href="http://business.bostonherald.com/businessNews/view.bg?articleid=49568&amp;amp;format="&gt;&lt;strong&gt;Crash in the Condo market&lt;/strong&gt;&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Condo prices over the past year rose more than 14 percent - more than 10 percent faster than single -family home prices.&lt;br /&gt;&lt;br /&gt;"That's a sign that we ought to start looking very closely at this housing market," said Harvard University housing expert Nicholas Retsinas. "That may be a sign that the &lt;em&gt;slowing may be sooner than we think&lt;/em&gt;." &lt;br /&gt;&lt;br /&gt;Also related,&amp;nbsp;&lt;a href="http://business.bostonherald.com/businessNews/view.bg?articleid=56336"&gt;share value&amp;nbsp;of the largest US homebuilders has declined&lt;/a&gt;. &lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;table style="margin: 5px; width: 200px; border: darkslategray 2px dashed;" align="left" border="0"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a style="font-weight: bold;" href="http://news.bbc.co.uk/2/hi/business/4055891.stm"&gt;The greenback's decline is largely the result of &lt;em&gt;massive twin deficits&lt;/em&gt; - both in the federal budget, and in the current account which measures the difference between the flow of money in and out of the US.&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Global worries about the size of the US trade gap cause the &lt;strong&gt;US dollar to hit a &lt;/strong&gt;&lt;a href="http://news.bbc.co.uk/2/hi/business/4037903.stm"&gt;&lt;strong&gt;record low against the euro&lt;/strong&gt;&lt;/a&gt;. It doesn't help that our Federal Reserve chairman, &lt;a href="http://news.bbc.co.uk/2/hi/business/4037903.stm"&gt;Alan Greenspan &lt;em&gt;announced&lt;/em&gt; &lt;strong&gt;the gap was unsustainable&lt;/strong&gt;&lt;/a&gt;. It probably also doesn't help that the Chinese central banker has made comments stating &lt;a href="http://www.reuters.com/newsArticle.jhtml?type=businessNews&amp;amp;storyID=6946082&amp;amp;src=rss/businessNews"&gt;&lt;strong&gt;China would be reducing dollar assets in its reserves&lt;/strong&gt;&lt;/a&gt;. Though he later retracted his comment, he will probably &lt;em&gt;still reduce the dollar&lt;/em&gt; asset.&amp;nbsp;European Central Bank chief Jean-Claude Trichet reiterated concerns that &lt;a href="http://news.bbc.co.uk/2/hi/business/4055891.stm"&gt;the sliding dollar was "unwelcome" for the European economy&lt;/a&gt;. &lt;br /&gt;&lt;br /&gt;Even though the &lt;a href="http://news.bbc.co.uk/2/hi/business/4044133.stm"&gt;US dollar has "bounced back"&lt;/a&gt; from the record low, many still have &lt;strong&gt;a negative outlook towards the future of the dollar&lt;/strong&gt; and &lt;em&gt;expect it to fall farther&lt;/em&gt;. &lt;a href="http://news.bbc.co.uk/2/hi/business/4044133.stm"&gt;[1]&lt;/a&gt; &lt;a href="http://www.reuters.com/newsArticle.jhtml?type=businessNews&amp;amp;storyID=6946082&amp;amp;src=rss/businessNews"&gt;[2]&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;Effects from the drop in the US dollar can already be seen in a &lt;a href="http://story.news.yahoo.com/news?tmpl=story2&amp;amp;u=/ap/20041130/ap_on_bi_st_ma_re/wall_street"&gt;drop in the DOW&lt;/a&gt;. Though &lt;a href="http://business.bostonherald.com/businessNews/view.bg?articleid=56336"&gt;S&amp;amp;P Drops&lt;/a&gt; may be mostly due to Wal-Mart (thanks Wal-Mart). &lt;br /&gt;&lt;br /&gt;With a national debt of &lt;a href="http://www.publicdebt.treas.gov/opd/opdpenny.htm"&gt;$7.5+ trillion dollars&lt;/a&gt;, &lt;a href="http://www.brillig.com/debt_clock/"&gt;&lt;strong&gt;$25,535.54&amp;nbsp;of debt for &lt;em&gt;each&lt;/em&gt; American citizen&lt;/strong&gt;&lt;/a&gt;, (and growing fast) and our record breaking trade deficit, it's hard to see the light at the end of the tunnel. &lt;br /&gt;&lt;br /&gt;So what is "our great leader", President Bush, doing about this? &lt;a href="http://www.cbsnews.com/stories/2004/03/12/politics/main605544.shtml"&gt;He sends in a $2.4 trillion dollar budget&lt;/a&gt; and &lt;a href="http://www.cbsnews.com/stories/2004/11/20/politics/main656797.shtml"&gt;&lt;strong&gt;HE RAISES OUR NATIONAL DEBT LIMIT&lt;/strong&gt;&lt;/a&gt;. Apparently our problem is not that we owe too much, our problem is OUR LIMITS ARE NOT HIGH ENOUGH. I wonder why we have a national debt limit, if &lt;a href="http://slate.msn.com/id/2109203/"&gt;we're able to breach the limit without any problems&lt;/a&gt;.&amp;nbsp; I guess it's more of a suggestion than a "limit".&lt;br /&gt;&lt;br /&gt;Our budget is still&amp;nbsp;bloated and contains many&amp;nbsp;&lt;strong&gt;"pet projects" that &lt;/strong&gt;&lt;a href="http://story.news.yahoo.com/news?tmpl=story2&amp;amp;u=/latimests/20041124/ts_latimes/petprojectsunleashedinspendingbill"&gt;&lt;strong&gt;total more than $15.8 billion&lt;/strong&gt;&lt;/a&gt;. They found $250,000 for the Country Music Hall of Fame in Nashville, $1 million for the B.B. King Museum in Indianola, Miss., and $75,000 for the Paper Industry International Hall of Fame in Appleton, Wis. &lt;br /&gt;&lt;br /&gt;Bush is also asking congress for &lt;em&gt;an additional $87 billion dollars&lt;/em&gt; to "continue the fight on terrorism in Iraq". &lt;em&gt;So far&lt;/em&gt;, it is&amp;nbsp;estimated this &lt;strong&gt;"war on terrorism" will end up costing the US &lt;/strong&gt;&lt;a href="http://www.crunchweb.net/87billion/"&gt;&lt;strong&gt;$191 billion dollars&lt;/strong&gt;&lt;/a&gt;. This site has a javascript counter of &lt;a href="http://costofwar.com"&gt;how much the war is currently costing us&lt;/a&gt;.&amp;nbsp; You can also find out how much it is costing your State, or even County. Check out &lt;a href="http://www.crunchweb.net/87billion/"&gt;this link&lt;/a&gt;, they provide a cute visualization of $191 billion dollars.&lt;br /&gt;&lt;br /&gt;As if we have any problems getting into debt ourselves, the laziness of the Bush administration has also allowed a violation the laws of The World Trade Organization, &lt;a href="http://story.news.yahoo.com/news?tmpl=story2&amp;amp;u=/nm/20041126/ts_nm/trade_wto_sanctions_dc"&gt;&lt;strong&gt;costing us an &lt;em&gt;initial&lt;/em&gt; $150 million&lt;/strong&gt;&lt;/a&gt;. &lt;a href="http://news.bbc.co.uk/2/hi/business/4045979.stm"&gt;[2]&lt;/a&gt; This is like a $150 million dollar parking ticket, Bush being our driver, unfortunately we will all have to pay for it. &lt;br /&gt;&lt;br /&gt;It seems that Bush wants to spend more money than he is allowed, so where will he find all the money for this? Easy! &lt;strong&gt;Bush will just&amp;nbsp;&lt;/strong&gt;&lt;a href="http://www.reuters.com/newsArticle.jhtml?type=domesticNews&amp;amp;storyID=6933798&amp;amp;src=rss/domesticNews"&gt;&lt;strong&gt;borrow from social security&lt;/strong&gt;&lt;/a&gt;! He doesn't have to run for re-election, so what does he care. &lt;br /&gt;&lt;br /&gt;Maybe &lt;a href="http://www.freep.com/news/politics/taxgrid23e_20041023.htm"&gt;we would have been better off with John Kerry&lt;/a&gt;. It's a shame and very apparent that our voting system does not work. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Great Links about our National Debt:&lt;/strong&gt; &lt;a href="http://www.brillig.com/debt_clock"&gt;http://www.brillig.com/debt_clock&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;table style="margin: 5px; width: 200px; border: darkslategray 2px dashed;" align="left" border="0"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a style="border-right: medium none; border-top: medium none; font-weight: bold; border-bottom: medium none; border-: medium none;" href="http://news.bbc.co.uk/1/hi/business/3701042.stm"&gt;"In plain English, deficits have to be financed by borrowing and large scale debt, with the risk of &lt;em&gt;large-scale default&lt;/em&gt; and large-scale disruption and pain."&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;I'm still having troubles finding economic reports stating "everything is OK". Even &lt;a href="http://news.bbc.co.uk/1/hi/business/3701042.stm"&gt;reports like this&lt;/a&gt;, which suggest growth is strong, leave suggestion that &lt;strong&gt;it will not last&lt;/strong&gt;. &lt;br /&gt;&lt;br /&gt;Don't skip by that "large-scale default" too quickly. By default, he means failure to pay or bankrupcy. And large-scale could potentially include the US banks or the US itself. He's saying, if trends continue, the US may have to declare bankrupcy. This most-likely&amp;nbsp;will not&amp;nbsp;happen, but that doesn't mean that it couldn't happen.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;My suggestions:&lt;/strong&gt; Read all the links in this article. Do your own research. Sell your house &lt;em&gt;or&lt;/em&gt; refinance with a fixed rate. Pay off all debt. Start saving for our future recession.&lt;/p&gt;</description><pubDate>Tue, 19 Jul 2011 07:57:28 GMT</pubDate><guid isPermaLink="true">http://www.joel.net:80/us-has-a-90-chance-of-economic-doom</guid></item></channel></rss>
