ASP.NET
The Cheyenne Project – Part 1
0In 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:
Here is what the Entities and the Repository classes look like:
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!
0Yeah, 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!
UrlMappings — An ASP.NET feature I forgot about
0So, the other day I came across a situation where I needed to provide a link to a user to a specific page within my web application; but that link also required that I provided specific values for a couple query string parameters which would take them right to the data they was looking for. I wanted to avoid the messy looking querystring at the end of the URL so I wondered if there was some way around it. I started thinking and the first thing came to mind was a URL mapping feature. After some poking around on Bing, I was taken to a MSDN page that reminded me that ASP.NET starting with version 2.0 came will a simple url mapper that would be perfect for what I was trying to accomplish.
To get the feature to work, all you have to do was add configuration element to your web.config and then you are off and running. Here is what it looked like:
<urlMappings> <add url="~/SomePageThatDidNotHaveToExist.aspx" mappedUrl="~/SomePageThatHasToExist.aspx?id=123&cat=somecat" /> </urlMappings>
Once you place this section in the <system.web> section, all your users would have to access is the SomePageThatDidNotHaveToExist.aspx page and ASP.NET would translate that url into the actual url with the additional querystring parameters at the very end. So, I didn’t have to use any third party components since my needs were very simple. Hope you find some use for this forgotten feature. Until next time…
Happy Programming!
A little late to the game
0There 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:
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!
Forgotten AJAX Extenders
0Today, I started a project on CodePlex called Forgotten AJAX Extenders. The purpose was to create my own Ajax control based on the ASP.Net Ajax Control Toolkit. The toolkit comes with a nice set of pre-built controls; but I think a few controls were left out and that was the reasoning behind the Forgotten AJAX Extenders project name. The first control under development is the Textbox Character Count Extender. I posted a lengthy explanation about what this extender control does on my project home page. Please let me know what you think and if there is a feature that you fell is missing, please use the Discussions tab to provide me with your comments. Well, that’s all for now. Until next time…
Happy Programming!
Free ASP.NET Security Screencast Series
0Pluralsight is a .NET training company that use to only offer on-site instructor lead courses. However, beginning late last year they launch a new version of their website with the main feature being On-Demand video training. Even though this on-demand training feature isn’t free, they have provided some free training for you to sample. Last week I sat and watch their entire ASP.NET Security training series and I really learned a lot. If I had the money, I would pay for their entire online training courses. These guys are good. Anyways, I just thought I should share that with you. Until next time…
Happy Programming!
Microsoft lands another big client
0Check out WhiteHouse.gov. It’s running on the ASP.NET platform. I also noted that the Presidential Inaugural Committee streamed live video of the swearing in ceremony. I would say, Microsoft landed a big, very big client. Until next time…
Happy Coding!
Detecting Session Timeouts using a ASP.Net MVC Action Filter
34Some 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!
ASP.NET MVC Beta Released!
0Scott 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!
ASP.NET and Password TextBox with initial value
1Some asked me a question the other day about an issue they were experiencing with pre-loading a password text box with some initial text. Here is what their code looked like:
ASPX
<asp:TextBox id="txtPassword" runat="server" TextMode="Password" />
Code-Behind
txtPassword.Text = "mypassword";
But, when the page loaded, there was no value contained in the password text box. So, what’s the issue? Apparently, this is a restriction that the ASP.NET developers thought that should be in place due to security reasons. However, a workaround for this is to add the value to the attributes collection of the web server control:
txtPassword.Attributes.Add("value", "mypassword");
Doing this would cause the Value attribute of the <input type="password"> HTML control to be populated. So, here is what will be sent to the browser for rendering:
<input type="password" id="txtPassword" name="txtPassword" value="mypassword" />
It should be noted that even though the value of the password will be masked in the browser, the value will show up in clear text if you view the page source. So, if this is not the behavior you would like to have, then this is not the solution for you. Hopefully, this was of some help to you.
Until next time…
Happy Coding!