ASP.NET MVC剃刀传递模式来布局 [英] ASP.NET MVC Razor pass model to layout

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

问题描述

我看到的是一个字符串布局属性。但我怎么能传递一个模型来明确布局?

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

推荐答案

好像你已经仿照你的ViewModels有点不对劲,如果你有这个问题。

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

我个人从来没有输入页面布局。但是,如果你想这样做,你应该有一个基础视图模型,你的其他的ViewModels继承并键入布局的基础视图模型,你的页面的具体一次。

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剃刀传递模式来布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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