My career has largely been spent creating line of business applications and that is the priority focus of the framework. Eventually I would like to expand on that but with limited time you have to simplify or get no where. I also didn't intend for it to be particularly opinionated but I'm naturally getting pushed that way. Again I hope to make it more flexible in future but for now it's simply not a priority.
The first casualty of this is routing, otherwise known as pretty URL's. This feature is simply not that important in a line of business app and it simplifies things to not have to worry about it at this point. For now, the only route is /{controller}/{action}/{querystring}.
The other big decision I made is project structure. I'm sick of having various parts of an application strewn about the project, or several projects, based on type. The grouping of this framework is going to be done by function. A standard project layout will be along the lines of:
- MvcProject
- -\_Common
- ---_Layout.cshtml
- -\Product
- ---_Controller.cs
- ---List.js
- ---List.cshtml
Let there be Light
So I created a new web application and in the global.asax.cs I put:
- protected void Application_Start(object sender, EventArgs e) {
- RouteTable.Routes.Add(new Route("{*url}", new RequestHandler()));
- }
This tells ASP that we want to handle all incoming URL's with our request handler, which is all I want for now. RequestHandler looks like this:
- public class RequestHandler : IRouteHandler, IHttpHandler {
- IHttpHandler IRouteHandler.GetHttpHandler(RequestContext requestContext) { return this; }
- bool IHttpHandler.IsReusable { get { return true; } }
- void IHttpHandler.ProcessRequest(HttpContext context) {
- context.Response.Write("Hello World!");
- }
- }
IRouteHandler and IHttpHandler are the interfaces we need to implement to recieve requests from ASP. I'm not sure if it's a good idea to combine them or not but it works for now. The real meat and potatoes starts with ProcessRequest though, it might not look like much but this is the entry point to our framework. This is where the adventure begins.