ASP.NET MVC Razor 将模型传递给布局 [英] ASP.NET MVC Razor pass model to layout

查看:35
本文介绍了ASP.NET MVC Razor 将模型传递给布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到的是一个字符串布局属性.但是如何将模型显式传递给布局?

What I see is a string Layout property. But how can I pass a model to layout explicitly?

推荐答案

如果您遇到此问题,您似乎对视图模型的建模有点错误.

Seems like you have modeled your viewmodels a bit wrong if you have this problem.

就我个人而言,我永远不会输入布局页面.但是如果你想这样做,你应该有一个你的其他视图模型继承的基本视图模型,并将你的布局输入到基本视图模型,然后你将页面转到特定的一次.

Personally I would never type a layout page. But if you want to do that you should have a base viewmodel that your other viewmodels inherits from and type your layout to the base viewmodel and you pages to the specific once.

这篇关于ASP.NET MVC Razor 将模型传递给布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆