This project has moved and is read-only. For the latest updates, please go here.

It's probally not working in MVC 4

Nov 14, 2013 at 8:39 AM
I'm just tried to use this MVC Extensions and I see no evidance of result. Maybe I'm doing something wrong. I'm just installed it from nuget and attribute [MinifyHtml] to my method. Can you help me?
Nov 14, 2013 at 10:07 AM
Hello, Sntlv!

Switch a web application to release mode by using the following settings in the Web.config file:
<?xml version="1.0" encoding="utf-8"?>
    <compilation debug="false"  … />
Nov 14, 2013 at 11:22 AM
I tried that too. Changed build mode, no result. Anything else?
P.S.: Thank you in advance.
Nov 14, 2013 at 11:38 AM
Try to read documentation and explore a example project (WebMarkupMin.Example.Mvc).
Nov 14, 2013 at 12:20 PM
Copied all html/ core and webextension part of config andd add only [minifyhtml] attribute, run release mode - no result. Read all docs and looked through project. Maybe I need some magic?
Nov 14, 2013 at 12:26 PM
Is it it suppose to work with IIS Express?
Nov 14, 2013 at 12:28 PM
Try significantly increase the value of maxResponseSize property:
<?xml version="1.0" encoding="utf-8"?>
   <webMarkupMin xmlns="">
      <webExtensions maxResponseSize="…" />
Nov 14, 2013 at 12:33 PM
maxResponseSize="5000000" still nothing =))
Nov 14, 2013 at 12:40 PM
But your project is doing good. I downloaded it and tried out on IIS Express.
Nov 14, 2013 at 12:42 PM
IIS Express is supported.

Frankly, I don't know why you have these errors. Create a new ASP.NET MVC application, and try to install WebMarkupMin.Mvc.
Nov 14, 2013 at 12:42 PM
Is it working with .Net Framework 4.5?
Nov 14, 2013 at 12:44 PM
.Net Framework 4.5 and 4.5.1 is supported.

May be you are using a CMS?
Nov 14, 2013 at 12:47 PM
MVC 4 is supported.
Nov 14, 2013 at 12:48 PM
Nov 14, 2013 at 12:48 PM
Hmm, no, I'm not. How can I debug this or what are known issues? For me it is just not working at all, no errors. But in your test project everything is fine.
Nov 14, 2013 at 12:49 PM
OK, I'll try =))
Nov 14, 2013 at 12:52 PM
Make your test project on the basis of ASP.NET MVC 4 and .NET Framework 4.5.
Nov 14, 2013 at 12:55 PM
Still not working even in a newly created web app. I can send it if you want.
Nov 14, 2013 at 12:59 PM
Waiting for your test project.
Nov 14, 2013 at 1:04 PM
Nov 14, 2013 at 1:10 PM
Do you speak Russian?
Nov 14, 2013 at 1:12 PM
Конечно =))
Nov 14, 2013 at 1:19 PM
А что это у нас в Web.config написано?
<?xml version="1.0" encoding="utf-8"?>
    <compilation debug="true" targetFramework="4.5" />
Nov 14, 2013 at 1:24 PM

У меня только 2 объяснения:
  1. Ты троллишь мой проект.
  2. Ты совсем не внимательный.
Nov 14, 2013 at 1:24 PM
Я запускал с релизом и с debug="false". Попробуйте сами.
Nov 14, 2013 at 1:26 PM
Попробовал и у меня работает.
Nov 14, 2013 at 1:30 PM
У тебя наверное и скрипты со стилями не минимизируются?
Nov 14, 2013 at 1:37 PM
Странно, у меня тоже заработало. Прости, если отвлекаю. Но сначала оно не работало, правда. Теперь не работает только в основном проекте. Если я мешаю, я могу сам поэкмпериментировать.
Nov 14, 2013 at 1:39 PM
Скрипты и стили я отдельно минимизирую при сборке проекта. Вот решил попробовать HTML минимизировать. Уже пол дня бьюсь, не получается. Видимо совсем руки кривые у меня =))
Nov 14, 2013 at 1:45 PM
Закрываем обсуждение.

У меня есть статьи про WebMarkupMin на русском: «WebMarkupMin HTML Minifier – современный HTML-минимизатор для платформы .NET» и «HTML-минимизация в Web Essentials 2013».
Mar 8, 2014 at 9:21 AM

Thanks for creating and sharing this. Does this work if I am using a CMS? I get a reflection load error after installing.
Mar 8, 2014 at 9:27 AM
Hello, Austin!

Describe error in detail.
Mar 9, 2014 at 3:45 AM
Edited Mar 9, 2014 at 3:49 AM
Thanks for your reply.

Can you confirm that this library with work with a CMS? You asked a question above "Are you using CMS?". I am using Sitefinity from Telerik. It has the capability to run WebPages and MVC and WebPages/MVC Hybrid. I see no reason why it should not work it is standard after all.

In the setup I was testing I had a MasterPage that I modified to be derived from MinifiedAndCompressedHtmlPage.

Here is the exception that is thrown when I tried to compile the solution after adding WebMarkupMin via Nuget.

Error 114 Unable to load assembly 'SitefinityWebApp, Version=6.3.5000.0, Culture=neutral, PublicKeyToken=null' : Could not load file or assembly 'WebMarkupMin.Core, Version=, Culture=neutral, PublicKeyToken=99472178d266584b' or one of its dependencies. General Exception (Exception from HRESULT: 0x80131500)
System.SystemException: Unable to load assembly 'SitefinityWebApp, Version=6.3.5000.0, Culture=neutral, PublicKeyToken=null' : Could not load file or assembly 'WebMarkupMin.Core, Version=, Culture=neutral, PublicKeyToken=99472178d266584b' or one of its dependencies. General Exception (Exception from HRESULT: 0x80131500) ---> System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.RuntimeModule.GetTypes()
at System.Reflection.Assembly.GetTypes()
at Telerik.OpenAccess.Metadata.MetadataAttributesReader.PrepareMetaModelTypes(Assembly assembly)
--- End of inner exception stack trace ---
at Telerik.OpenAccess.Metadata.MetadataAttributesReader.PrepareMetaModelTypes(Assembly assembly)
at Telerik.OpenAccess.Metadata.MetadataAttributesReader.ReadMetaModel(Assembly assembly)
at Telerik.OpenAccess.Metadata.AttributesMetadataSource.<>c__DisplayClass1.<FromAssembly>b__0()
at Telerik.OpenAccess.Metadata.AttributesMetadataSource.CreateModel()
at Telerik.OpenAccess.Metadata.MetadataSource.GetModelCore(MetadataContainer old)
at Telerik.OpenAccess.Sdk.Enhancer.Enhancer.CrossDomainRunImpl(AssemblyLoader assemblyLoader)
at Telerik.OpenAccess.Sdk.Enhancer.EnhancerBase.CrossDomainRun() C:\Dev\MAIN\Source\SitefinityWebApp\obj\Debug\SitefinityWebApp.dll SitefinityWebApp

The solution is being compiled against .net 4.5.1 AnyCpu.

I temporaily removed the libary and rolled back to an alternative solution, but I would love to get this working since WebMarkupMin seems to have some really nice features.

I am also starting out to use your excellent BundleTransforms project. I had concerns about whether or not WebMarkupMIn would double up the minification that was going on. I came to the conclusion that WebMarkupMIn would only minify and compress pages served by Sitefinity and any inline scripts or styles that appeared on that page and that BundleTransforms would minify any externally referenced scripts and styles. Is this conclusion correct?

Mar 9, 2014 at 6:58 AM
What modules you are using in the project: WebMarkupMin.Web, WebMarkupMin.Mvc or WebMarkupMin.WebForms?

WebMarkupMin only minify inline scripts or styles. For external scripts and styles you should use the another solution (for example, Bundle Transformer).
Mar 9, 2014 at 7:27 AM
About the error: it seems to me that you have updated WebMarkupMin.Core to the latest version and forgot to move in the Web.config file the following settings:
<?xml version="1.0" encoding="utf-8"?>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <assemblyIdentity name="WebMarkupMin.Core" publicKeyToken="99472178d266584b" culture="neutral" />
        <bindingRedirect oldVersion="" newVersion="" />
Mar 9, 2014 at 12:30 PM
Due to the fact that Sitefinity supports Webforms MVC and Hybrid I actually installed.

Minifier.ASP.NET MVC Extensions
Minifier.ASP.NET Web Forms Extension

I assumed that since I just installed from Nuget it would auotmatically apply the latest version. I do not recall upgrading.

I'll give it another try with the binding redirect. Hopefully that will get me going with this.

Thanks again.
Mar 14, 2014 at 11:16 PM
Just given this another try. Still get the same error. The binding redirect was automatically added to the web.config.

My refrences look like the following.
<Reference Include="WebMarkupMin.Core">
<Reference Include="WebMarkupMin.MsAjax">
<Reference Include="WebMarkupMin.Mvc">
<Reference Include="WebMarkupMin.Web">
<Reference Include="WebMarkupMin.WebForms">
Maybe I need to compile the source against .net 4.5.1 AnyCPU? Other than that I am at a loss as to why this is not working.
Mar 15, 2014 at 2:28 PM
Give me an example of code, that uses WebMarkupMin.
Mar 15, 2014 at 6:20 PM
Edited Mar 16, 2014 at 12:03 PM
The only test that I have run so far is a WebForms master template that is used for the site theme.
<%@ Master Language="C#"   Inherits="SitefinityWebApp.App_Data.Sitefinity.WebsiteTemplates.EC.App_Master.main" CodeFile="main.master.aspx.cs"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="" >
<head id="Head1" runat="server">
    <script type="text/javascript" src="" language="javascript"></script>
    <script src="/Scripts/jquery.easing.1.3.js"></script>
    <script src="/Scripts/jquery.mousewheel-3.0.6.pack.js"></script>
    <script src="/Scripts/jquery.fancybox.js"></script>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" /> 
    <meta http-equiv="content-language" content="en-gb">
    <link runat="server" rel="shortcut icon" href="~/favicon.ico" type="image/x-icon" />
<link runat="server" rel="icon" href="~/favicon.ico" type="image/ico" />

    <!--[if IE]>
        <link href="/Sitefinity/WebsiteTemplates/EC/App_Themes/EC/Styles/internet_explorer.css" rel="stylesheet" type="text/css" />

<body class="main-body">
    <form id="form1" runat="server">     
<asp:ScriptManager ID="ScriptManager1" runat="server" />    
        <div id="wrapper">
            <div id="userstrip-holder">
                <div id="userstrip">
                    <asp:contentplaceholder id="userstrip" runat="server" />

                <div id="toggle">
                    <%--<asp:Literal id="mylit" Text="<%$Resources:Labels, toggle_user_menu %>" runat="server"/>--%>
                    <asp:Literal id="Literal1" Text="Toggle User Menu" runat="server"/>
            <div id="header-holder">
                <div id="header">
                    <div id="main-navigation-login">
                        <asp:contentplaceholder id="mainnavigation" runat="server"/>
            <div id="content">
                <asp:contentplaceholder id="content" runat="server" />
                <div id="footer">
                    <asp:contentplaceholder id="footer" runat="server" />
And the code behind file for this master page looks like.
using System;
using System.Web.UI;
using WebMarkupMin.WebForms.MasterPages;

namespace SitefinityWebApp.App_Data.Sitefinity.WebsiteTemplates.EC.App_Master
    public partial class main : MinifiedAndCompressedHtmlMasterPage

        protected void Page_Init(object sender, EventArgs e)
            this.Page.ViewStateUserKey =
            this.Page.User.Identity.IsAuthenticated ? this.Page.User.Identity.Name : "default";
I am going to try a few more experiments to try and get this working.
Mar 15, 2014 at 8:06 PM
Try to update WebMarkupMin to version 0.8.18.

From what type originally inherited the main class?
Mar 16, 2014 at 10:13 AM
Taritsyn wrote:
Try to update WebMarkupMin to version 0.8.18.

From what type originally inherited the main class?
I'll try the update later.

main inherits from MasterPage so I think it is fairly standard.
Mar 16, 2014 at 1:54 PM
Got it working with that update! Also had to modify to derive from MinifiedAndCompressedXhtmlMasterPage rather than MinifiedAndCompressedHtmlMasterPage. But solution compiles with either so the update has fixed something for me. Thanks!
Mar 16, 2014 at 4:44 PM

In this update all modules was explicitly compiled for one version of core. In addition, was a slightly increased performance of core.
Mar 17, 2014 at 1:10 PM
Good man! I appreciate your efforts.

I'll be testing this out over the coming months with Sitefinity in Hybid MVC/Webforms mode. I'll post any issues I encounter.

Is there a simple way to enable performance diagnostics? It would be nice whilst in Debug mode to know what savings are being made.

BTW I am in Ukraine are you in Ukraine or Russia?
Mar 17, 2014 at 2:33 PM
Edited Mar 17, 2014 at 2:33 PM
Is there a simple way to enable performance diagnostics?
You need to write and register your own logger (look the Info method and MinificationStatistics class).
It would be nice whilst in Debug mode to know what savings are being made.
I recommend to look the properties of webExtensions configuration section.

All these topics are described in the documentation. If you speak Russian, I recommend you to read my article «WebMarkupMin HTML Minifier – современный HTML-минимизатор для платформы .NET».
BTW I am in Ukraine are you in Ukraine or Russia?
I live in Russia.