视图渲染问题
在我的应用程序中,我有两个母版页,它们用于各种不同的情况。假设一个主视图仅渲染页面的上半部分,而另一个主视图则渲染上半部分以及侧面的导航栏。我们使用视图模型将数据传递到这些母版页
现在,在我的控制器中,我的索引操作引用带有导航栏和不需要导航栏的详细信息选项卡的母版页。但是,现在每当我尝试呈现“详细信息”页面时,我的网站都会在 Site.MasterWithNavigation 处崩溃,尽管它现在不涉及我的详细信息视图。我不知道它是如何降落在那里的。
在连接调试器并检查 pae 崩溃的位置时,它显示它在 Site.MasterWithNavigation 处崩溃,在检查调用堆栈时,只有一个条目将我带到另一个 Site.Master 并在随机部分显示异常查看渲染线。我想只是为了让我注释掉那一行,然后再次看到崩溃发生在我渲染 HTML 输入元素的另一行。
知道为什么我会看到这个吗?请注意,我们还有其他页面使用第二个母版页,但由于某种原因,它们都位于名为 WhateeverDetailsController 的不同控制器中。当我们在同一控制器内的两个不同操作中使用两个不同的母版页时,您认为存在问题吗?
In my application I have two Master pages and they are used in various different cases. Say one master view just renders the top half of the page and another master view that renders the top half plus a navigation bar to the side. We pass around data to these Master pages using view models
Now in my controller my index action refers to the MasterPage with the navigation bar and a details tab that does not need the navigation bar. But there is a problem now whenever I try to render the Details page my site crashes at the Site.MasterWithNavigation although it is noway involved with my details view. i have no clue how it lands up there.
On attaching the debugger and checking where the pae is crashing it showed me it is crashing at the Site.MasterWithNavigation and on checking the call stack there was just one entry which took me to my other Site.Master and showed the exception at a random partial view rendering line. I thought just for the heck of it let me comment out that piece of line and again saw the crash occurring now at a different line where I render an HTML input element.
Any idea why the hell I am seeing this? Note we have other pages that use the second master page but for some reason they are all in a different controller called WhateeverDetailsController. Do you think there is a problem when we use two different master pages across two different actions within the same controller.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道为什么你要一起使用多个母版页,但我只使用一个母版页,并向所有页面公开相关标签,例如:
你可以很容易地对页面的顶部、侧面和标题执行相同的操作使用 css 来设置所有内容的样式。
I am not sure why you are using multile master pages together but I use one master page only, and expose relevant tags to all pages such as:
You could very easily do the same for the top part of your page, side part and title and use css to style everything up.