Chris Pietschmann

husband, father, hacker, entrepreneur, futurist, innovator, autodidact

NAVIGATION - SEARCH

Mocking HttpRequestBase.ServerVariables using Moq

Mocking is a very handy tool for unit testing code, especially when it comes to mocking the HttpContext for web application code. However, it’s not as straight forward as you might think to mock the HttpRequestBase.ServerVariables, however once you know what to do it really is pretty simple. Here’s a code example (using moq) that shows how to create a mock HttpContextBase that contains a mock HttpRequestBase with a mock ServerVariables property: public HttpContextBase CreateMockHttpContext() ... [More]

ASP.NET MVC Themes: 3 different theming methods

There really isn’t a single “one size fits all” solution to theming an ASP.NET MVC web application. From my experience working with the platform, there are really 3 different methods that can be used to theme your apps. Here they are in no particular order: 1. CSS Stylesheet This is the simplest and pretty much standard method that’s used to theme an ASP.NET MVC web application. Basically, you just create a different version of your sites CSS file for each “theme.” Then you include the approp... [More]

MvcXaml - Images from XAML within ASP.NET MVC Application

It can be cumbersome using GDI+ to dynamically generate images based on data. I recently had to perform some dynamic image generation within an ASP.NET MVC application, and had the idea of using XAML to define what the image will look like. In a relatively short amount of time, including searching the web and looking at Anoop Madhusudanan’s example, I successfully put together a proper ASP.NET MVC ViewEngine to perform this task. Download MvcXaml with Samples! Basics of Usage After you regi... [More]

HTML5 Day 4: Add Drop Down Menu to ASP.NET MVC HTML5 Template using CSS and jQuery

Today I was playing around with using jQuery to create a drop down menu. I thought I’d share an example of adding a drop down menu to the new ASP.NET MVC HTML5 Template that I created on Day 2. Before we begin, you’ll need to create a new site using the code from Day 2. You can either copy/paste the code from the article, or download the full source code. You’ll find the download link at the bottom of the post for Day 2. Here’s a screenshot of the finished dropdown menu: ... [More]

HTML5 Day 2: Upgrade ASP.NET MVC 2 Site Template to HTML5

Since HTML5 can be used in older browsers with some helper scripts, as covered in Day 1, I thought I’d use what I’ve learned to convert the default ASP.NET MVC 2 site template to HTML5. Convert Default ASP.NET MVC Site Template to HTML5 First, add the helper scripts, mentioned in Day 1, to the Site.Master and convert all magical DIVs over to “header”, “section”, “nav” and “footer” tags. Don’t worry about copy/paste, a download lin... [More]

MvcMaps Preview 1 – A Unified Bing/Google Maps API for ASP.NET MVC

I spent some time lately working on bringing some of the concepts of Web.Maps.VE to ASP.NET MVC. The concepts I’m referring to are Simplicity and Ease of Development in making the implementation of mapping within ASP.NET MVC applications as simple as possible along with the Flexibility and Customizability of the Base Mapping API itself. Then I thought, Since I’m building an abstraction layer to simplify Bing Maps development, why not implement it in a flexible manor as to be able to ... [More]

A Simple ScriptManager for ASP.NET MVC

The ASP.NET AJAX ScriptManager makes it really easy to include JavaScript references and register JavaScript blocks into the rendered Page output of an ASP.NET WebForms application. However nice the ScriptManager control is, it’s still just a WebForms control for use with ASP.NET AJAX; thus it’s use isn’t really supported with ASP.NET MVC. Also, to make things just a little more difficult, ASP.NET MVC doesn’t have it’s own “ScriptManager” implementation.... [More]

Prototype of VEToolkit + ASP.NET MVC 1.0 Component Checked In

I just checked in an initial prototype of a reusable Virtual Earth component for ASP.NET MVC. The “VEToolkit.Web.MVC.Map” component is written as an Extension to the ASP.NET MVC AjaxHelper class, and allows for a simpler experience when implementing Virtual Earth mapping within ASP.NET MVC applications. This is an early prototype of what the component will be; it’s not a final release; but you are free to use it. Download the latest Change Set of VEToolkit The code is subject to change at any ... [More]

ASP.NET MVC: Implement Theme Folders using a Custom ViewEngine

One of the things that ASP.NET MVC 1.0 is missing is the ability to easily implement Themes. The older, more mature standard ASP.NET framework includes theme support via the App_Themes folder; however limited it can be, it’s still more than ASP.NET MVC currently has. Well, at least until I wrote this little custom ViewEngine and ControllerBase class to help out and allow us to very easily implement Themes within our ASP.NET MVC applications. A little history: A few months back I wrote up a... [More]

Custom Themes in ASP.NET MVC Updated for Preview 5

Update 2009/03/26: There is an updated version of this code (with improvements) that targets the ASP.NET MVC 1.0 RTW located here: http://pietschsoft.com/post/2009/03/ASPNET-MVC-Implement-Theme-Folders-using-a-Custom-ViewEngine.aspx  About two weeks ago I posted on how to Implement Custom Theme support in ASP.NET MVC. There were some breaking changes made when the Preview 5 release was released yesterday. Here's a short list to a couple of the changes I had to make to my code from the previ... [More]

How To Setup Custom Theme Support In ASP.NET MVC Preview 4 using a Custom ViewEngine

Update 2009/03/26: There is an updated version of this code (with improvements) that targets the ASP.NET MVC 1.0 RTW located here: http://pietschsoft.com/post/2009/03/ASPNET-MVC-Implement-Theme-Folders-using-a-Custom-ViewEngine.aspx  Update 8/29/2008: I posted a new blog post today that contains updated code for this example that works with the newly released ASP.NET MVC Preview 5. The new code is located here. One option to do theming in ASP.NET MVC is to use the standard ASP.NET Theme fun... [More]

How To Use ASP.NET MVC in Website rather than Web Application Project

I recently started getting to know the ASP.NET MVC Framework (more specifically the Preview 4 release). The first thing I noticed upon installation is that it only comes with a Web Application Project Template. There is no regular ASP.NET Website template. So, I decided to try converting the Web Application Project Template to a regular ASP.NET Website. I actually prefer to use Website projects instead of Web Application projects since it gives a little more flexibility to deploy changes to the ... [More]