I am not using ASP. NET mvc3 for a long time and have insufficient experience. Therefore, please note the mistakes.
Mvc3 is also a web development framework. As a web development platform, it will inevitably involve the call relationship between parent pages and child pages. What are the methods in mvc3?
Based on your current situation, there are two ways to choose from:
1. similar to ASP. the masterpage method that appears in net 2.0, that is, add: renderbody () call to the parent page, and add a reference to the parent page in the Child page: Layout = .... If this method is used, the browser must start from the Child page, so that the child page content will be merged to the renderbody () function of the parent page during the call. Otherwise, the system will prompt an error: the file cannot be directly requested "~ /Views/home/*****. cshtml ", because it calls the" renderbody "method.
2. remove the reference of the Child page to the parent page: Layout = ..., remove the call to the renderbody () function on the parent page, and use the command @ HTML to call the subpage. partial ("******"). Interestingly, if the called Child page references another parent page in method 1, it is interesting to add a child page and another parent page. This method seems to be more flexible than method 1, so that a single subpage can be referenced by multiple parents. This method is more like a weak type reference, method 1 is like a strongly typed reference.