How to upload bundled and minified files to Windows Azure CDN

前端 未结 4 1577
感动是毒
感动是毒 2020-12-07 16:50

I\'m using the ASP.NET MVC 4 bundling and minifying features in the Microsoft.AspNet.Web.Optimization namespace (e.g. @Styles.Render(\"~/content/static/css\")).

4条回答
  •  春和景丽
    2020-12-07 17:38

    You can define origin domain as Azure's website (this probably was added long after the original question).

    Once you have CDN endpoint, you will need to allow query string for it and then you can reference directly to bundles via CDN:

    
    

    I've also created this helper to append CDN host name:

    public static IHtmlString RenderScript(string virtualPath)
    {
        if (HttpContext.Current.IsDebuggingEnabled)
            return Scripts.Render(virtualPath);
        else
            return new HtmlString(String.Format(
                CultureInfo.InvariantCulture, 
                Scripts.DefaultTagFormat, 
                "//CDN_HOST" + Scripts.Url(virtualPath).ToHtmlString()));
    }
    

提交回复
热议问题