.Net

ScriptControl question

As of late I have gotten a chance to use the ASP.Net AJAX extenders and script controls, and so far am really liking how they work, though it would be nice if adding the .js was a little cleaner then manually adding them to the assembly wether in the AssemblyInfo.cs or the controls cs file. I have to say I really like the extender and script controls that come with the ASP.NET AJAX. They really are so much nicer to work with then building up Javascript strings in the CS file of the server control. I do...

Lazy list

I have been following Rob Conery's posts on the MVC Storefront, and trying the repository/pipes-filters for data access that he has been using. While trying out the implementation of a LazyList he was using, I had noticed that the example table was being joined onto the category table. At the time however, I really had not thought much of it, until I read MVC Storefront: Brainbender Intermission which got me thinking. Admittedly, I don't really have to much of a problem with it loading all of the examples for all the categories at one time at the moment. However,...

ABCs scare me

I had a whole post about this, in my mind, but as I was typing, I kept poking holes in my points as to why I hope that in the end IHttpContext stays around. However, since am trying get into the habit of actually sleeping at night I'm just going to put a couple of sentences in. In Abstract Base Classes Have Versioning Problems Too Haacked gave an example that of a problem with ABCs, that at some point later a virtual method would be added, and throw a not implemented exception. This in itself seems to be a breaking...

I think I'm missing something

I finally found time to work on DevExamples.com again and thought I would check on the suggestion that Richard had left on Got my nice Urls working about using incremental LINQ. Overall I found that I liked the following syntax much better var cats = this.Categories.Where(c => c.Name == navList.First().Value); foreach (var item in navList.Skip(1)) { string name = item.Value; cats = cats.Where(c => c.Name == name); } cat = cats.First(); Unfortunately this only works for the first parent in the hierarchy. After the first parent, it continues to simply work off of the single join. The problem...

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 = ...

Subtext Admin Rss Feeds

I just committed the changes to provide 3 administrative rss feeds: Comments Needing Moderation Referrals Errors The change also uses the HttpModule that will convert forms authentication into basic authentication so that the feeds can be viewed in an Rss reader. After seeing http://msdn2.microsoft.com/en-us/library/Aa479391.aspx I had thought about changing over to use it instead of the simple module I wrote. I decided not to however because it would have meshed well with Subtexts security model. This was one of the more interesting things I have worked on in a while, though I am already thinking of several improvements that...

HttpHandlers and web.config settings

I figured out what was happening in my previous post. It makes a bit more sense now that I have seen it, being able to just stop working on something is handy, basically the Rss feeds don't do URL rewriting. So the call to /test1/Admin/ModeratedCommentRss.aspx uses the /web.config and would use the /test1/Admin/web.config, but it has no reason to look at the /Admin/web.config. Not completely sure how I should change this. Right now I have the ModeratedCommentRss.aspx checking to see if the requestor is an Admin, and if not it calls FormsAuthentication.RedirectToLoginPage(). This works, but I would rather a solution that didn't...

HttpHandlers and directory authentication/HttpModules

I decided to implement  Admin Rss Feeds after a particularly draining Friday. For the most part it went pretty smoothly, and learned something about working with a different team too ;). I Implemented an HttpModule that looked for FormsAuthentication redirects for rss feeds and changed it over to use basic authentication so rss readers could authenticate. And for a while all was good. In fact other then unit tests I had thought I was done. Then just to be thorough I set up several subfolder blogs off of localhost, and everything stopped working. Apparently something in the way that the rss HttpHandlers...

I wish C# 3.0 was here already

I was reading IHttpContext And Other Interfaces For Your Duck Typing Benefit over on Haacked. It reminded my of something I did Thursday, which made me wish that .Net 3.5 was already usable. I actually finally convinced my boss to let me try to automate at least some of the testing. So first order of business, change our the SQL installer program we use to allow it run without user interaction. After a good amount of refactoring of the monolithic control function, I get that part working. It can now do everything it needs to do by passing in all...

WF and WCF books

I have read most of the Essential Windows Workflow Foundation book by Dharma Shukla and Bob Schmidt. I would definitely recommend it for anyone who is just starting with WF or who is just curious as to the why features were implemented a certain way. This book probably is not for you however if you are looking for a more hands on book. Which brings me to the next book, which I wish I had started first, Learning WCF: A Hands-on Guide by Michele Leroux Bustamante. While a lot of the information in the book is available on the web, having the...

Building my "sit and read" muscle

After doing some spring cleaning over the last few weeks, I have found that I had a stack of books on various topics that I had meant at one point to read. I also decided that I would like to actually read most of them, but am finding that I have a relatively weak "sit and read muscle". Looking back I’m not all that surprised by this fact, though I am a little annoyed with myself because of it (and determined to fix it). This does however seem to only be effect non-fiction reading. Its not so much that my "sit and read...

Change of web host

I finally decided to downgrade the hosting package that I have with MaximumASP from a dedicated server to a virtual private server. So far the new server has been good. The only real problem I have had is that I signed up for the the lower end VPS, which only has 394MB of memory, subtext seems to be taking up a good amount of it. Hopefully setting the application pool to recycle at 45MB doesn't cause any problems.

Copyright © Sean Lynch

Design by Bartosz Brzezinski

Design by Phil Haack Based On A Design By Bartosz Brzezinski