June 4, 2015 06:40 by Dan
One of the best things about using a compiled language over a scripting language is that you get compile-time checks that prevent run-time errors later. ASP.NET MVC uses a hybrid approach by default. Views are compiled at run-time, but controllers, models, and other classes are pre-compiled. MVC also allows you to create strongly-typed views, but since those views aren’t compiled until run-time, you don’t always get warned about changes to your models (like property name changes) or other errors in your view until it’s running.
There’s a simple way to change this, though, by setting the views to build at compile time. Unfortunately this setting isn’t exposed in the Project Properties page in Visual Studio, but can still set it up manually. Here’s how:
>> Right-click on your project file in Visual Studio’s Solution Explorer and choose Unload Project.
>> Right-click the project file again and choose Edit YourProject.csproj.
>> Look for a node called <MvcBuildViews> in the first <PropertyGroup> node (the one without any other attributes). If it’s not there, add it.
>> Add or update the value inside the <MvcBuildViews> node to true. When you’re done it should look like this:
>> Save the project file changes.
>> Right-click the project file in Solution Explorer one last time and select Reload Project.
Your views will now be built at compile -time and you will get syntax errors from any mistakes in your Razor syntax or breaking changes to your model, and you’ll get them long before your code makes it in front of users.
Keep in mind that, though, if you like to edit your .cshtml files while you’re running the debugger, these changes will no longer show up in the browser until you recompile the application again. I guess you can’t have it all!
Best ASP.NET Hosting Recommendation
ASPHostPortal.com provides its customers with Plesk Panel, one of the most popular and stable control panels for Windows hosting, as free. You could also see the latest .NET framework, a crazy amount of functionality as well as Large disk space, bandwidth, MSSQL databases and more. All those give people the convenience to build up a powerful site in Windows server. ASPHostPortal.com offers ASP.NET MVC hosting starts from $1/month only. They also guarantees 30 days money back and guarantee 99.9% uptime. If you need a reliable affordable ASP.NET Hosting, ASPHostPortal.com should be your best choice.