Blog Post

Working with embedded view compilation issue resolved

Tuesday, September 8, 2015 2:54 PM

I have found when I have embedded view in project quite challenging and want to share my experience.

Case scenario

I have two projects

  • Main UI project (ASP .NET Web Application)
  • Components (Class Library)


  Main project refers to Areas that are implemented in my components project, for this example the area is 'user' area. For our example we have file Index.cshtml in that area

The issue

When we make any change to our view and save and then refresh the browser we get a compilation error. The error basically say that the embedded view is out of date.

While working with normal view in main project, we expect to make the change and refresh browser, and this does not happen. Therefore we need to recompile all for each change.

This costs us time and the company money.


How do we work around that?

The answer is simple, Partial views.


Guide how to:

Create your main embedded view with the container (that does not change)

in my case validation of user and container for content called Index.cshtml


Create partial view that contains all or most of your UI called _userProfile.cshtml.

Now your index page will call partial using code as  


This will allow us to modify the partials views on runtime without recompiling the solution every time.



Last posts

12/01/19 - Hybrid Cloud

12/01/19 - Private cloud

12/01/19 - Public Cloud

21/12/18 - Accessing Raspberry PI 3 B

16/10/18 - ICloud installation into Outlook 365 isn't configured to have a default profile