是否有可能重新使用在ASP.NET MVC多个项目的部分看法? [英] Is it possible to reuse partial views on multiple projects in ASP.NET MVC?

查看:126
本文介绍了是否有可能重新使用在ASP.NET MVC多个项目的部分看法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道ASP.NET MVC 3不支持区域重用,这将是非常方便的,比如说,Web应用程序的用户管理领域,但如何对部分看法?

I know ASP.NET MVC 3 doesn't support area reuse, which would be very handy for, say, user admin areas of web applications, but how about partial views?

说我有寻呼机控制为剃须刀(或 WebFormViewEngine ,也没关系)部分查看我可以我的 MVC 应用程序中轻松地重用。

Say I have Pager "control" as a Razor (or WebFormViewEngine, it doesn't matter) partial view which I can easily reuse inside my MVC application.

是否有可能在新的应用程序创建一个部分视图重新使用它在其他多个应用程序的MVC比和复制粘贴code?

Is it possible to reuse it in multiple MVC applications other than by creating a partial view in the new application and copy-pasting the code?

推荐答案

有什么BUIT,它允许你这样做的框架。你可以看看<一个href=\"http://www.lostechies.com/blogs/hex/archive/2010/04/07/mvccontrib-portable-area-visual-studio-project-template.aspx\"相对=nofollow> MVCContrib便携领域它允许你嵌入和重复使用多个ASP.NET MVC应用程序之间的意见。您也可以找到的以下博客帖子有用的。

There is nothing buit-in the framework that allows you to do this. You may take a look at MVCContrib portable areas which allows you to embed and reuse views between multiple ASP.NET MVC applications. You may also find the following blog post useful.

免责声明:这两个方法依赖于编写自定义的VirtualPathProvider 其中不起作用以precompiled ASP.NET应用程序。所以,如果你在发货前打算precompile您的应用程序不使用这些。我个人在这种情况下,什么我最后做的是写一个<一个href=\"http://docs.nuget.org/docs/creating-packages/creating-and-publishing-a-package#Creating_a_Package\"相对=nofollow>它包含了所有含有各自的视图模型和所有开发者必须做的是从一个中央位置withing通过Intranet / Internet安装的NuGet包所需的意见和装配定制的NuGet包。

Disclaimer: both those approaches rely on writing a custom VirtualPathProvider which doesn't work with precompiled ASP.NET applications. So if you intend to precompile your application before shipping don't use those. Personally I am in this situation and what I ended up doing is writing a custom NuGet package which contains all the necessary views and assemblies containing their respective view models and all that a developer has to do is to install the NuGet package from a centralized location withing the intranet/internet.

这篇关于是否有可能重新使用在ASP.NET MVC多个项目的部分看法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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