使用 MVC3,我可以调用/使用另一个项目中的视图吗?
我没有看到有人谈论这个。我拥有的是三个项目共有的登录逻辑。我的模型在一个项目中(共享)。
我可以在另一个共享项目中拥有控制器和视图吗?我只是不想在每个内容中重复一些事情。
也对人们可能必须解决这个问题的任何其他想法感兴趣。
罗伯特
I didn't see anyone talking about this. What I have is login logic that's common to three projects. I have my model in one project (shared).
Can I have the controller and views in another shared project? I just don't want to have to duplicate things in each.
Also interested in any other ideas people may have to solve this problem.
Robert
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看预编译的 Razor浏览次数
Take a look at Precompiled Razor Views
好吧,当谈到加载视图时,您可以实现自己的 ViewEngine 并指示它从您想要的任何位置(数据库、dll 等)加载视图。我昨天刚刚看到 TechEd NA 的精彩视频,其中Spark 视图引擎展示了如何实现它。在您的情况下,您只需获取视图并将其输入到 razor 视图引擎中即可。您应该没有问题,因为 razor 被设计得非常灵活,您可以轻松地生成自己的引擎实例以让它呈现您加载的视图。
Well, when it comes down to loading views, you can implement your own ViewEngine and instruct it to load your view from wherever you want (database, dll, ...). I just saw a nice video from TechEd NA yesterday, where the creator of the spark view engine shows how to implement it. In your case, you can just fetch the view and feed it into the razor view engine. You should have no problems, since razor was designed to be flexible, and you can easily spawn your own instance of the engine to have it render your loaded view.