博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
编译MVC的views
阅读量:4953 次
发布时间:2019-06-12

本文共 1274 字,大约阅读时间需要 4 分钟。

Yes, you can do that. Compile your views for any release build you are trying to do. This will make sure everything compiles nicely and your users don’t see an “Error 500” when accessing a view. Of course, errors can still happen, but at least, it will not be the view’s fault anymore.

Here’s how you compile your views:

1. Open the project file in a text editor. For example, start Notepad and open the project file for your ASP.NET MVC application (that is, MyMvcApplication.csproj).

2. Find the top-most <PropertyGroup> element and add a new element <MvcBuildViews>:

<PropertyGroup>

...

<MvcBuildViews>true</MvcBuildViews>

</PropertyGroup>

3. Scroll down to the end of the file and uncomment the <Target Name="AfterBuild"> element. Update its contents to match the following:

<Target Name="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">

<AspNetCompiler VirtualPath="temp"

PhysicalPath="$(ProjectDir)\..\$(ProjectName)" />
</Target>

4. Save the file and reload the project in Visual Studio.

Enabling view compilation may add some extra time to the build process. It is recommended not to enable this during development as a lot of compilation is typically involved during the development process.

转载于:https://www.cnblogs.com/fanweixiao/archive/2009/05/09/1453268.html

你可能感兴趣的文章
Python3 图片转字符画
查看>>
[C陷阱和缺陷] 第7章 可移植性缺陷
查看>>
人需要治愈
查看>>
linux中configure文件默认执行结果所在位置
查看>>
Spring MVC例子
查看>>
jmeter 断言
查看>>
玩玩小爬虫——抓取时的几个小细节
查看>>
error C4996: 'fopen'
查看>>
Windows向Linux上传文件夹
查看>>
软件工程个人项目一:四则运算器
查看>>
Struts2拦截器之ModelDrivenInterceptor
查看>>
Docker 容器的通信(十二)
查看>>
非线性激活
查看>>
【转】Polya定理
查看>>
Lambda表达式中的表达式lambda和语句lambda区别
查看>>
Mac OS X Snow Leopard 开启Web共享,建立Web服务器:Apache+PHP+MySql
查看>>
20180104-高级特性-Slice
查看>>
6个SQL Server 2005性能优化工具介绍
查看>>
nginx启动、关闭命令、重启nginx报错open() "/var/run/nginx/nginx.pid" failed
查看>>
day14 Python 内置函数、匿名函数和递归函数
查看>>