cannot be loaded because the execution of scripts is disabled on this system

To enable running unsigned powershell scripts on your system.

Set-ExecutionPolicy Unrestricted

Easy!

Event handlers can only be bound to HttpApplication events during IHttpModule initialization.

If you ever get this error it is because you are trying to access the HttpApplication context outside of its intialisation pipeline and more than likely you are using IIS7.

This error is easily fixed you must add this code block to your Global.asax and move the offending code inside it and no more errors :)

public override void Init()
{
    base.Init();
    //offending code here
}

ASP.NET MVC StrongRoutes AppAir.Web Preview Release

Today is a preview release of the AppAir.Web utility library for ASP.NET MVC.

What is included is StrongRoutes and two helper functions to clean up your views. The general idea is you have static classes for routes so they can be referenced anywhere in your Controllers and Views without using nasty Magic Strings.

If you like what you see or have some suggestions give me a shoutout via here or tweeter @bleevo.

All code is licensed as MIT
Source Code: http://github.com/bleevo/AppAir.Web/tree/master
Direct Download: http://github.com/bleevo/AppAir.Web/zipball/master

View

<%=Html.LinkTo("Register", UserRoutes.Register)%>
<a href="<%=Url.LinkTo(UserRoutes.Register)%>">Register</a>

Global.asax

public class MvcApplication : System.Web.HttpApplication
{
	public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
		AppAir.Web.Routing.StrongRouteRegistrar.MapFrom(typeof(UserRoutes), routes);
    }
 
    protected void Application_Start()
    {
		RegisterRoutes(RouteTable.Routes);
	}
}
 
public static class UserRoutes
{
	[RouteOrder(2)]
	public static readonly StrongRoute Register 
		= StrongRoute.Map<UserController>("register", c => c.Register());
 
	[RouteOrder(1)]
	public static readonly StrongRoute Logout 
		= StrongRoute.Map<UserController>("logout", c => c.Logout());
 
	public static readonly StrongRoute Login 
		= StrongRoute.Map<UserController>("login", c => c.Login());
}