0

我正在为我的 Web 应用程序使用 Meleze.Web 库,并且我只想在发布版本上添加压缩。

我试图做一个 web.config 转换,但在 Web.Release.config 文件中,当我尝试做

<configuration>

   <system.web.webPages.razor>
      <host xdt:Transform="Replace" factoryType="Meleze.Web.Razor.MinifyHtmlWebRazorHostFactory, Meleze.Web, Version=1.4.0.3, Culture=neutral, PublicKeyToken=0a868b5321967eda" />
   </system.web.webPages.razor>

</configuration>

给我一个错误,说 :Transform 没有声明。任何帮助,将不胜感激。请注意,这是 Views 文件夹中的 Web.Config。

4

2 回答 2

0

您可以使用以下 Web.Release.config 文件来转换您的 Web.config 文件。

<?xml version="1.0" encoding="utf-8"?>

<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <!--
    In the example below, the "SetAttributes" transform will change the value of 
    "connectionString" to use "ReleaseSQLServer" only when the "Match" locator 
    finds an attribute "name" that has a value of "MyDB".

    <connectionStrings>
      <add name="MyDB" 
        connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True" 
        xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
    </connectionStrings>
  -->
  <system.web.webPages.razor>
    <host factoryType="Meleze.Web.Razor.MinifyHtmlWebRazorHostFactory, Meleze.Web, Version=1.4.0.6, Culture=neutral, PublicKeyToken=0a868b5321967eda" xdt:Transform="Replace" />
  </system.web.webPages.razor>

  <system.web>
    <!--
      In the example below, the "Replace" transform will replace the entire 
      <customErrors> section of your web.config file.
      Note that because there is only one customErrors section under the 
      <system.web> node, there is no need to use the "xdt:Locator" attribute.

      <customErrors defaultRedirect="GenericError.htm"
        mode="RemoteOnly" xdt:Transform="Replace">
        <error statusCode="500" redirect="InternalError.htm"/>
      </customErrors>
    -->
  </system.web>
</configuration>
于 2014-09-30T13:22:42.827 回答
-1

对我来说,它工作得很好。我遵循的步骤在这里:

  1. 通过包管理器控制台安装 Meleze.WebPM> Install-Package Meleze.Web
  2. 打开View/Web.config并将<host...../>里面的行<system.web.webPages.razor>替换为<host factoryType="Meleze.Web.Razor.MinifyHtmlWebRazorHostFactory, Meleze.Web, Version=1.4.0.3, Culture=neutral, PublicKeyToken=0a868b5321967eda" />

这就是我所做的。顺便说一句,我正在使用 MVC 4。

于 2012-11-24T18:09:54.430 回答