views:

251

answers:

3

Does there exist a method when publishing an ASP.NET MVC application to completely remove the .aspx view files (and if possible .master too) by compiling them into the application DLL as resources?

The published application would just be the /bin folder, Global.asax and web.config, a default.aspx if needed, and whatever is in the /Content folder. All the views would be contained in the MyProject.dll file.

To clarify I don't mean where every .aspx is overwritten with a 1 line dummy file referencing the correct resource, but where those files can be eliminated entirely in the published app.

The goal here is to simply change management and all the auditing and layers of people surrounding it - one file gets deployed, that file replaces the existing file, and no messing around with a stack of .aspx files that have to be added/removed/updated (yes, SVN or a similar solution handle that problem instead, but management politics prevent this).

+1  A: 

Is this what you are looking for?

JSC
This looks like it is on the right track, I had expected I'd need to overide behavoir somewhere to make it happen. It will be a few hours before I can try fleshing this out to a full solution.
David
A: 

我已经把ASPX转成了CS文件,除了运行期省去了一次转换和一次编译外,其最大的好处是容易项目管理和版本发布,但是随着实际应用发现,把ASPX 转换成CS类编译到DLL文件里,对我们的平台来说并不是最好的,因为我们做的是一个基于元数据驱动的开发平台,把ASPX转换成CS类同样没有体现出我们平台的特性(元数据驱动),所以最终的做法是运行期解析屏幕UI定义,动态生成视图,这样一来即去掉了ASPX又体现了我们的平台特性,还不用把ASPX转换成CS类,可谓一举三得,经过测试发现,这样的改动并没有影响运行效率,第一次访问一个页面时,比原有的ASPX要快很多,第二次基本和走ASPX的方式的运行效率是一样的。

檀迎军
A: 

It's possible with the web forms view engine but you'll have to extend the path provider yourself.

Here is a question here at SO about the same thing: Using VirtualPathProvider to load ASP.NET MVC views from DLLs

If you use the Spark view engine, it already has additional path providers built in.

The documentation can be found here: Adding a view folder to config

It allows you to locate your views inside a DLL as an embedded resource, somewhere else on the file system, using the default virtual directories, or plug in your own custom provider.

Jay