Geeks With Blogs

News Please visit me at my new blog!!

profile for Aligned at Stack Overflow, Q&A for professional and enthusiast programmers
"free in Christ Jesus from the law of sin and death." Romans 8:2 (ESV) Check out the Falling Plates video on YouTube.
more about the Gospel
And then listen to Francis Chan speaking at LifeLight in SD.



Programming and Learning from SD

MVC can work with .cshtml or .aspx pages (you can mix Web Forms and Razor views in the One ASP.Net that Scott Hanselman talks about). This means MVC will search for a view with endings of .aspx, .ascx, .cshtml, .vbcshtml, in the Controller directory (if you have a HomeController, then it it would look in Views/Home, then Views/Shared). If you aren’t using aspx pages it’s doing extra work it doesn’t need to do. See Dave Ward’s post on the importance of using debug=false and Marcin Doboz’s post on MVC Performance for more details.

In your Global.asax.cs Application_Start() you can override this behavior.

protected void Application_Start()
{
    // code
    // since we aren't using web forms .aspx, remove from the view engines
    ViewEngines.Engines.Clear();
    ViewEngines.Engines.Add(new RazorViewEngine());

    // more code...
}

Setting debug=false (always in Production!) in the web.config and changing the ViewEngines will get MVC running even better.

Posted on Friday, May 31, 2013 8:10 AM MVC , Performance | Back to top


Comments on this post: MVC Performance Tip

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Aligned | Powered by: GeeksWithBlogs.net