繁体   English   中英

通过CDN的T4MVC

[英]T4MVC through CDN

我想将我的静态内容移动到CDN。 但是我喜欢(爱吗?)T4MVC,并希望继续使用它。 因此,理想情况下,我只想将生产中的“ http:// mysite”替换为“ http:// cdnaddress / path”。 有人尝试过吗? 会有陷阱吗?

在T4MVC.tt.settings.t4中查找ProcessVirtualPathDefault:

// You can change the ProcessVirtualPath method to modify the path that gets returned to the client.
// e.g. you can prepend a domain, or append a query string:
//      return "http://localhost" + path + "?foo=bar";
private static string ProcessVirtualPathDefault(string virtualPath) {
    // The path that comes in starts with ~/ and must first be made absolute
    string path = VirtualPathUtility.ToAbsolute(virtualPath);

    // Add your own modifications here before returning the path
    return path;
}

通过调整此代码,您应该能够实现所需的功能。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM