December 2007 Entries

Got my nice Urls working

Its amazing how fast things can be done when not fighting bad assumptions. In this case it was that my admin URLs needed to use the nice descriptive URLs, instead of just /[Controller]/[Action]/[id] type routing. Once I realized I was making things overly complicated I, I ended up with a set of routing functions that are actually a bit less complicated then what I would have come up with if I had been able to extend the RouteTable the way I had planned originally. I also decided that I didn't like the idea of having the make every category and...

Temp service provider implementation

Well, Bill Pierce in his post about making the HttpContext wrapper use the application as a service provider got me to a good enough solution for the script service I had wanted in my previous post. While not quite as clean as adding it to the HttpContext, I think an extension method on HttpApplication like this will work well for now. public static object GetService(this HttpApplication application,Type service) { IServiceProvider provider = application as IServiceProvider; if (provider == null) return null; return provider.GetService(service); } Then add/implement the IServiceProvider...

I feel so behind sometimes

I was trying to determine the best way to secure my admin* actions when I thought of something I had only really seen while studying for my MCSD.Net exams, or maybe it was the MCPD upgrade exams I haven't gotten round to taking. I decided to secure the admin controller actions using. [PrincipalPermission(SecurityAction.Demand,Role="<Role>")] Which I had never used even though I started programming .Net in during the beta of 1.0. And I have to admit that each time I run into something like this, it makes me feel that my thought in a previous post is right. This works for my immediate...

Generic begin/end Html tag extension method

After working on the login usercontrol, I decided that I wanted to add similar functionality to the navigation sections of the site for accounts/roles that didn't get ads displayed. So I needed a standard way to put dynamic sections into a page. I liked the syntax used by the form HtmlHelper methods, so decided to base it off of the SimpleForm class and ended up with this//Based on the SimpleForm class in MvcToolkit //Wish I believed I would have ever thought to use//IDisposable to do thispublic class SimpleWrappingTag : IDisposable{ protected string _beginTagFormat = "<{0} {1}>"; ...

Login via Usercontrol View + jQuery

Since administration was the next part I wanted to work on. I decided that for the moment I just want a little login for in the upper corner like I decided to put the login screen view logic into a user control, and added the following user control named Login.ascx and placed it into the Shared <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> <%if(!Page.User.Identity.IsAuthenticated) {%> <form action="/Home/Login" method="post" id="LoginForm"> <span id="EmailLabel">Username:</span><br /> <%=Html.TextBox("Username")%><br /> <span id="PasswordLabel">Password:</span><br /> ...

Routing revisited

It turned out to be a lot easier to work around not being able to override the route parsing method then I had thought it would be last night. Though when they allow me to override that method I will be changing over. By setting up the following routes I was able to get almost the effect that I was looking for:RouteTable.Routes.Add(new Route { Url = "Example/[id]/[action]", Defaults = new { Controller = "Example" }, RouteHandler = typeof(MvcRouteHandler) }); RouteTable.Routes.Add(new Route { Url = "Example/[Category1]/[id]/[action]", Defaults = new {...

Initial thoughts on Microsoft MVC

My first thought is, I really wish I could use this at work, but it is working nicely so far for my rewrite of my web site. Writing Classic ASP style again is taking a little getting used to again though, the visual preview from the designers made styling the page a lot nicer. The lack of control designers also seem like it would hinder having a graphics guy using Expression Web do the UI with MVC based web applications. But I have never worked with a graphics guy on a project that way anyway so I am could...

I think the 3.5 framework might be the straw

Yesterday my boss had me upgrade the project files of our main app to use Visual Studio 2008. While doing this the migration wizard asked if I wanted to upgrade the app to work against the .Net 3.5 framework. He had said to just migrate the solution files for now, and later when there was time we would upgrade the framework version. Then he asked something I hadn't really thought about. "Does the .Net 3.5 framework support Windows 2000?" And its been quite a while since a single question had essentially ruined my day, but this one...

LINQ, Anonymous Types and Interfaces Revisited

After making my previous post I worked on it a bit more, and found that the best way to accomplish what I was trying to do, creating quick data layer that I can change later, was to simply add the IExample interface to the partial class definition. I know I can create this with Subsonic or anotherĀ  DAL generator, but currently they aren't on the list of tech I want to learn at the moment. And while this did work, I ran into an error in the dbmI designer when I clicked "View Code" from the context menu: This seems...

Anonymous Types and Interfaces

I finally had a chance to sit and work with LINQ for a bit, and while it is very cool, a little bit of its luster was lost when I can assign interfaces to the anonymous classes generated by the queries. Meaning I can not do something like: public interface IExample { string Name { get; set; } string Description { get; set; } } public class DataGenerator { public IEnumerable<IExample> GetExamples(string categoryName) { //Context Definition IEnumerable<IExample> examples = ...

Copyright © Sean Lynch

Design by Bartosz Brzezinski

Design by Phil Haack Based On A Design By Bartosz Brzezinski