ASP.NET

The Cheyenne Project – Part 1

In my last post I told you that I was going to work on a project that was “for me–by me”.   The project idea that I eventually decided on was a job board application that was very Web 2.0 centric and played nicely with the social networking websites that are so popular today.  I finally got around to finding a “code” name for this project and doing some initial project setup work.

So, what’s up with the name Cheyenne? Good question.  Well, after a few days I couldn’t find a good name I like so I decided to use my 20 month old daughters middle name. Yes, Daddy has a soft spot and she is it!

This web application will be built using the ASP.NET MVC framework.  I will be using a SQL 2008 Express database and using LINQ to SQL as my data layer.  I will be using the Repository Pattern to provide some layer of abstraction over my data layer just in case I want to easily swap out my data access implementation.  

 

Here are some screen shots of what the project looks like in Visual Studio 2008:

 

cheyenne_vsproject

 

Here is what the Entities and the Repository classes look like:

 

Entities

 

 

Repository

 

I want to see the code!  Ok…I was just getting to that. I uploaded the first installment to my Windows Sky Drive account and you can download it below:

 

Let me know what you think. There is currently no user interface! Actually, the MVC project don’t currently run at the moment; but the project does compile. I removed all the defaults that the MVC project gave me since I wanted to start out from scratch. Hopefully, by the next installment I will have a basic UI and have some data loaded on the screen.  If you have any suggestions or comments, let me know. Until next time…

 

Happy Programming!

Let’s build something!

Yeah, that’s what software developers do right?  For a while I have been thinking about building a web application where I can simple have some fun doing it and not have to worry about deadlines or business users changing the requirements every other week.  Don’t get me wrong, that’s all a part of being a professional software developer; but I think it is time to do something, “for me — by me”.

So, I’ve decided on building a job board application. No, I’m not trying to be the next Monster.com, although that would be nice. I just want to provide something that is simple to use and plays nicely with the social media networks that have gotten so popular over the past few years. Here are a list of features that I have so far:

  • ASP.NET MVC Application
  • Simple and clean user interface
  • Simple interface to search the job board.
  • All job postings are public
  • Easy authentication ( OpenId, Facebook Connect, Custom )
  • Web  2.0 centric  ( AJAX, RSS, IE8 Slices )
  • Allow easy sharing job postings with popular social networking sites ( Twitter, Facebook, Digg )
  • Allow only registered user’s to respond to job postings in a private manner.
  • Allow job posters to respond to job inquiries.
  • Provide an easy to use interface for any registered user to post a job
  • Job posting can be tagged with certain keywords.
  • Provide a mechanism for user’s to provide feedback for the overall site

Ok. Easy enough?  Well, If I’m going to pull this off then I will have to get familiar with many of the social media integration API platforms since this will be the first time using any of them. But; have no fear. There is a lot of resources out there to look at and most of all, I have YOU here to help me.

I’m not sure how long this is going to take. I do have a full-time job and I do have to spend time with my family and like I said, no deadlines! I will try to provide a part one to this series of blog post within a week. Oh, I just broke my rule about no deadlines. Until next time…

Happy Programming!

A little late to the game

There have been two recent releases that I have been playing around with.  First, Windows 7 was just released for MSDN subscribed members and being one, I was able to download and install within 48 hours. The download took almost 12 hrs since I had to compete with everyone else. However, take my word, it’s worth the wait. I’ve been using Windows Vista for about 2 yrs now and even though it was a nice improvement over Windows XP, it wasn’t ready when it was released and I pretty much considered it to be a BETA product. That has all changed with Windows 7 and this is what we should have gotten in the first release.

Secondly, ASP.NET MVC 2 Preview was recently relapsed for us to play around with and provided our feedback to the Microsoft developer team. I consider myself to be more of a web developer and I think this is the framework I’ve been waiting for. Don’t get me wrong, I still prefer ASP.NET Web Forms for certain projects; but if you are looking to build a Web 2.0 centric application that has SEO friendly URL’s and clean markup, then you should be using ASP.NET MVC. You can find out more information about this new release by checking out the following blogs:

Scott Gu

Phil Haack

Scott Hanselman

 

I would also recommend you subscribing each of their blogs if you want to keep up to date with ASP.NET MVC or ASP.NET in general. Until next time…

 

Happy Programming!

Detecting Session Timeouts using a ASP.Net MVC Action Filter

Some time ago, I read an article on how to detect a session timeout in a ASP.Net Web forms application by placing some code in a Base Page. The code worked for me and you could read more about it here.  In my last post I mentioned that Microsoft released a beta version of their MVC implementation of ASP.Net and since them, I have been playing around with it. But, as with Web forms, I still needed a way to detect a session timeout and perform an action when a timeout is detected. So, I decided to use the same code implemented in the original article and implement it into my MVC project. I decided to write a custom action filter and apply it to my controller actions where I need to ensure that my session was still active. Here is the code for my action filter.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Reflection;

namespace Web {

    public class SessionExpireFilterAttribute : ActionFilterAttribute {

        public override void OnActionExecuting( ActionExecutingContext filterContext ) {
            HttpContext ctx = HttpContext.Current;

            // check if session is supported
            if ( ctx.Session != null ) {

                // check if a new session id was generated
                if ( ctx.Session.IsNewSession ) {

                    // If it says it is a new session, but an existing cookie exists, then it must
                    // have timed out
                    string sessionCookie = ctx.Request.Headers[ "Cookie" ];
                    if ( ( null != sessionCookie ) && ( sessionCookie.IndexOf ( "ASP.NET_SessionId" ) >= 0 ) ) {

                        ctx.Response.Redirect ( "~/Home/Login" );
                    }
                }
            }

            base.OnActionExecuting ( filterContext );
        }
    }
}

And then, I would apply this filter to my Controller action methods like so:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;

namespace Web.Controllers {

    public class HomeController : Controller {

        [SessionExpireFilter]
        public ActionResult Index( ) {
            // This method will not execute if our session has expired

            // render Home Page
            return View();
        }

        public ActionResult Login() {
            // render Login page
            return View();
        }
    }
}

The code is pretty straightforward. I just apply the [SessionExpireFilter] attribute on each method where I want to ensure that our session is still valid. If you have any questions, leave a comment under this post. Until next time…

Happy Coding!

kick it on DotNetKicks.com

ASP.NET MVC Beta Released!

Scott Gu has all the details.  I’ve been waiting for the beta release before I really started digging into this MVC framework.  I am a Web Forms guy; but I have been waiting for a “structured framework” to come instead of dropping controls on a page and writing UI code behind each page. Based on all of the reading that I have seen, I like what I see.

For a purely web forms developer, which I am not, don’t expect to get all the fancy controls like GridViews, Validation controls, Login Controls, etc, like you would get out of the box in a web forms project. With ASP.NET MVC, HTML is your friend and if you are intimidated by writing HTML, then you probably shouldn’t be a web developer in the first place. However, this is the concept of HTML Helpers that you can use to assist you in generating pretty much all of the HTML input controls just by using some script code; but it is not mandatory. 

So, this will be a breath of fresh air for me. I am working on a  project now and I will be developing it using the MVC framework. I like working with new stuff and hopefully I will be able to share my experience as I go along. Until next time…

 

Happy Coding!