in

Platinum Bay

Peace, Love, and...

This Blog

Syndication


.NETicated

Static Page Checking in ASP.NET MVC

If you have built an ASP.NET web forms site of any substance, you have undoubtedly been bitten when code in the web form becomes outdated due to code change. It’s easy to see when the page is open in Visual Studio, as the code has red squiggles and the error shows up in the Error List tool window. As soon as the page is closed however, that error disappears. Even running a build will be successful. For some of my sites, which have over 150 pages, this can be very annoying to say the least.

ASP.NET MVC has a neat hidden feature to solve this problem. The MVC team was most likely were stung by the same issue more than once. This feature is static page checking during compilation. Unfortunately, instead of being an option in the Properties window for the project (future release idea?), it is in the *.*proj xml file itself. To enable this feature:

  1. Right-click on the Project node in the Solution Explorer tool window
  2. Choose “Unload Project” - Note: If your project is under version control, you will be prompted to do a check-in. Simply click “Continue” to ignore the check-in request.
  3. Right-click the Project node again
  4. Choose “Edit *.*proj", and the project file will now open in Visual Studio with color coding and IntelliSense
  5. In the first PropertyGroup node, there is a new node named MvcBuildViews
  6. By default this is set to false. Simply change the value to true
  7. Right-click the Project node and choose “Reload Project”
  8. If prompted that the file is already open, click yes to close the xml view.
  9. Build your project

You will notice that builds take longer than they did prior to this change. This is because under the covers, MSBuild is now making an additional call to aspnet_compiler in the AfterBuild MSBuild target:

C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v temp -p "[physical path]"

To avoid this delay in day-to-day development, you may choose to copy the MvcBuildViews node into the build-specific PropertyGroup nodes, and set it to false for Debug and true for Release.

Update: @jglozano points out that this only works with the default WebForms View Engine.

Hope this helps

Published Aug 21 2009, 02:35 PM by Steve
Filed under: ,

Comments

August 21, 2009 11:42 AM

Yes, this is a very important thing to do and for some reason it isn't widely known. Thanks for sharing it with the community :)

 

August 21, 2009 7:21 PM

Hi Steve,

Yeah this is a great tip that never really made it out of the release notes to common knowledge.  Thanks for publishing this.  There is one tip I would like to give though and I talked to Phil about this back in January, but it never made it in to the final release.  The actual path you want to use for the compile is not:

$(ProjectDir)\..\$(ProjectName)

it should just simply be

$(ProjectDir)

And I will tell you why.  The first one doesn't work if your assembly isn't named the same as your project.  The second one works every time and it probably isn't publicized all that much because of this bug, which is very easy to fix.  I know why this happened internally with in the MVC team, and it should have been fixed before the release, but these things happen sometimes.

 

August 22, 2009 5:17 PM

Pingback from  Twitter Trackbacks for                 Static Page Checking in ASP.NET MVC - .NETicated         [platinumbay.com]        on Topsy.com

 

August 22, 2009 10:15 PM

Pingback from  Twitter Trackbacks for                 Static Page Checking in ASP.NET MVC - .NETicated         [platinumbay.com]        on Topsy.com

 

August 23, 2009 12:54 PM

Pingback from  Arjan’s World    » LINKBLOG for Aug 23 - 2009

 

August 23, 2009 1:44 PM

Pingback from  Dew Drop – August 23, 2009 | Alvin Ashcraft's Morning Dew

 

August 23, 2009 5:43 PM

Thank you for submitting this cool story - Trackback from DotNetShoutout

 

August 24, 2009 5:40 PM

DotNetBurner - burning hot .net content

 

September 15, 2009 9:36 PM

Pingback from  ASP.NET MVC Archived Blog Posts, Page 1

 

February 19, 2010 4:58 PM

Soma online cod payment. Soma online sales. Buy soma online. Soma buy soma cheap soma soma online. Best online pricing for soma. Soma online.

 

May 20, 2010 8:54 PM

Pingback from  740i History, 740il Lamp Replacement Headlight

 

May 20, 2010 11:41 PM

Pingback from  Vx2265wm Widescreen Lcd Monitor, 265 Parts One

 

May 21, 2010 12:21 AM

Pingback from  Stanza Poetry Rhyme Royal Ottava Rima, 1992 Nissan Stanza Specs

 

May 21, 2010 12:35 PM

Pingback from  Legacy Audio Whisper 2003, 2010 Subaru Legacy Wagon Reviews

 

May 21, 2010 9:33 PM

Pingback from  Ford F100 Seat Cover, 1965 Ford F100 Headliner

 

May 22, 2010 4:05 AM

Pingback from  Motel 6 Ventura California, 1971 Pontiac Ventura 2 For Sale Fuel Pump

 

May 22, 2010 4:08 AM

Pingback from  D450 Pt Optical Zoom Digital Cameras, D450 Weight Lb

 

May 22, 2010 8:59 AM

Pingback from  Grand Prix Legends Discounts, 1998 Acura Legend Honda

 

May 22, 2010 2:02 PM

Pingback from  1999 Ford Falcon Au Futura, 1960 Ford Falcon Ranchero

 

May 22, 2010 2:34 PM

Pingback from  Bulb 530i Fog Light Bmw 740il, 1991 Volvo 740 Review

 

May 22, 2010 9:06 PM

Pingback from  E 350 Club Wagon Radiator 7.3 L Diesel Shock Absorber, 2007 Mercedes E350 Review Edmunds

 

May 23, 2010 12:40 AM

Pingback from  Armada Music Record Label Blake Jarrell, Compaq Armada M300 Bios

 

May 23, 2010 1:07 AM

Pingback from  1996 Volvo 960 Parts Radiator Hose Wiper Blade, 960 Boiler Maleic Anhydride Scale Inhibitor

 

May 23, 2010 7:33 AM

Pingback from  1992 Astro Van Fuel Pump, Angel Guide 450 - 242.animejin.com

 

May 24, 2010 1:01 PM

Pingback from  Chevy Pb15 Series Sale Crate, Pb150 Hpv - 139.defutbolazo.com

 

May 24, 2010 1:34 PM

Pingback from  1995 Mercedes Benz S Class S320 Lwb, S320 Cooling System - 220.unlockiphone30.net

 

May 25, 2010 1:18 AM

Pingback from  Quest Construction Software, 1995 Mercury Villager Gas Mileage Nissan Quest - 215.tgrconversions.com

 

May 25, 2010 5:36 AM

Pingback from  Monterey California Restaurants Montrio Bistro, Monterey Boat Reviews - 252.1fh.org

 

May 25, 2010 6:03 AM

Pingback from  735i Full Leather, Aftermarket Us Prices Bmw 735i - 455.rkwrh.com

 

May 25, 2010 6:24 AM

Pingback from  Download R20 Files, R20 Suburban Wholesale Discount - 67.computeronlinebingo.com

 

May 25, 2010 6:31 AM

Pingback from  Vacation Rentals In Durango Mexico, Custom Durango Rt - 412.unlockiphone30.net

 

May 25, 2010 6:44 AM

Pingback from  Buy Crucial Pb150, Pb150 Avenue - 198.cmanager.org

 

May 25, 2010 4:47 PM

Pingback from  Passport Headlight Auto Parts, Passport 51 - 296.animejin.com

 

May 25, 2010 6:14 PM

Pingback from  1997 Subaru Svx Radiator Hose Brake Caliper, Used Subaru Svx Body Kits - 56.rkwrh.com

 

May 25, 2010 6:56 PM

Pingback from  Premier Cell Model, Adobe Premiere Cut Scene - 492.renters.ws

 

May 25, 2010 10:42 PM

Pingback from  K30d Pickup Part Canon Camera, K30 Different Clinical - 150.mfbattle.com

 

May 25, 2010 11:55 PM

Pingback from  633csi Rental, Buy 6 Cylinder Engine Used Bmw 633csi - 423.defutbolazo.com

 

May 26, 2010 2:02 AM

Pingback from  C280 Part Sale Transmission, 280c Led Her - 22.renters.ws

 

May 30, 2010 11:49 PM

Pingback from  1984 - 2003 @ Mazda Protege5 Review Specifications, Protege5 Symptoms Mazda - 122.defutbolazo.com

 

May 31, 2010 12:01 AM

Pingback from  1981 - 2007 @ Buy Isuzu Impulse Geo Storm Air Intake, Impulse Electric - 286.dlmreza.net

 

May 31, 2010 12:05 AM

Pingback from  1993 - 1983 @ 1987 Mazda B2000 Replacement Tail Light, 86 B2000 Wheels Mazda B2300 - 101.tvshowzone.com

 

May 31, 2010 12:11 AM

Pingback from  1996 - 2004 @ Buy Lexus Lx450 Brake Pad Disc, Bulb Lx470 Replacement Lx450 2004 Lexus Gx470 - 305.eumreborn.com

 

May 31, 2010 1:53 AM

Pingback from  1991 - 2005 @ Garmin G1000, Buy Gnc G1000 Movie - 265.computeronlinebingo.com

 

May 31, 2010 6:10 PM

Pingback from  1999 - 1998 @ Lexus Sc430 Performance Upgrades, Sc430 Overview 2005 Lexus - 145.codebluehacks.org

 

May 31, 2010 7:17 PM

Pingback from  2004 - 1985 @ Bmw 630csi For Sale, 630csi Exhaust - 51.ja3ra.com

 

May 31, 2010 8:44 PM

Pingback from  2006 - 1982 @ Used 2002 Jeep Wrangler Sport Specs Suzuki Vitara, Part New Jeep Wrangler Rock Hard 4x4 Roll Cages - 133.zapstreaming.com

 

August 14, 2010 6:05 PM

Pingback from  Canon printer driver - Canon s520 - Canon i560 printer driver

 

Leave a Comment

(required )  
(optional )
(required )  
Add

About Steve

Steve Andrews is an independent consultant, INETA speaker, and Microsoft MVP for Visual Studio ALM. He has been working in technology for over ten years focusing on custom application development and Application Lifecycle Management. Steve is also Microsoft and IBM certified and a community fanatic having led sessions at nearly 100 events across North America. When he's not developing software solutions or engaging with the community about software technology, Steve is a closet singer and songwriter and plays the guitar and keys. Occasionally, Steve even gets to sleep. Occasionally.
Powered by Community Server (Commercial Edition), by Telligent Systems
© Platinum Bay | Some Rights Reserved Creative Commons License

Disclaimer: The information in this weblog is provided "AS IS" with no warranties, and confers no rights. This weblog does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion. Feel free to challenge me, disagree with me, or tell me I'm completely nuts in the comments section of each blog entry, but I reserve the right to delete any comment for any reason whatsoever (abusive, profane, rude, or annonymous comments) - so keep it polite, please.