If you are using ASP.NET MVC you might have noticed that you will not be alerted of build errors that exist in your views until you navigate to those pages. When you do so you'll get a runtime error L Thankfully there is a very easy way to change this. All you have to do is open the project file and change the value for the MvcBuildViews property to true. To do this, follow these steps.
- Right-click on the MVC project and select 'Unload Project'
- Right-click on the unloaded MVC project and select 'Edit …'. This will open up the project file itself, which of course is an MSBuild file.
- Look for the MvcBuildView property and set its value to true. It should be <MvcBuildViews>true</MvcBuildViews>
- Save the project file, right-click on the MVC project again and select 'Reload project'
After this if you introduce any build errors into the views then you will be notified when the project is built.
Sayed Ibrahim Hashimi
Monday, September 14, 2009 5:37:16 AM (GMT Daylight Time, UTC+01:00)
This weekend I will be speaking at the Tallahassee Code Camp on Saturday September 5, 2009. I will be presenting two sessions which are:
ASP.NET Custom View Helpers
If you have been using ASP.NET MVC then you certainly have been using some of the built in
view helper methods that are available, you know those expressions like
Html.TextBox("textBoxName") and Html.ValidationMessage("Required").
View helpers are nothing more than extension methods which create HTML that is injected into
your views based on the method and its parameters. Creating your own view helpers is very
simple and can be extremely beneficial. By writing your own custom view helpers you will
benefit in at least the following ways
- Simplifies Your Views
- Easies Rehydrating HTML Elements with ModelState Values
- Standardizes the Creation of Common HTML Components
- Helps you Implement the DRY (Don't Repeat Yourself) Principal
We will take an in depth look at how you can easily and effectively create your own view helpers. We will also discuss how the default view helpers were created and the benefits that they provide.
Utilizing Web Deployment Projects
In this session we will take a look at how Web Deployment Projects can be used to assist in the deployment of web sites and web applications; including ASP.NET Web Applications and ASP.NET MVC Web Applications. We will give an overview of what Web Deployment Projects are and the functionality that is available out of the box. A Web Deployment Project is a wrapper for the aspnet_compiler.exe tool in the form of an MSBuild project and adds value to using the tool itself. Because they are MSBuild files we are able to customize and extend the process. We will discuss how we can customize the process to perform common steps such as
- Creating Virtual Directories
- Updating values in the web.config file
- Encrypting the web.config file
- Versioning the Assemblies
If you are in the area and interested in these topics make sure to drop in!
Sayed Ibrahim Hashimi