Here's a minor bug that really foxed me until I managed to google the answer. With the latest MVC Framework code from CodePlex the routing has changed. It's now much more flexible, but one side effect is that it only kicks in if the requested resource can't be found on disk. So if you have a placeholder (blank) Default.aspx page in the root of your project as in previous versions of the MVC Framework, it actually gets rendered. Unfortunately you need that Default.aspx page for cassini (the Visual Studio development web server) to work. The work-around is to put a Response.Redirect in the code-behind of the Default.aspx placeholder:
public partial class _Default : Page { public void Page_Load(object sender, System.EventArgs e) { Response.Redirect("~/Home"); } }
The details about this can be found at Phil Haack's blog:
http://haacked.com/archive/2008/04/10/upcoming-changes-in-routing.aspx
Yeah, it's kind of a sucky work-around though. My own version, which isn't any better but doesn't require a code-behind file, is to put in a location.href = DEFAULTPAGE; in the default.aspx. Had a little conversation with Max Pool on this over Twitter and I think his version involved creating a route for default.aspx, deleting default.aspx, and setting RouteExistingFiles to false. Or something along those lines. Problem there is that you need to create routes for css and images too.
ReplyDeleteHi Kyle, I guess the thing that really sucks is that cassini doesn't work like IIS7, then we could just delete the default.aspx file and everything should work. Even so, I'd still need the work-around since I'm hosting on 2003 with IIS6.
ReplyDeleteI don't really like Max Pool's solution, the thought of putting routes in for all the static files sounds really irritating.