2

我想将我的静态内容移动到 CDN。但我喜欢(喜欢?)T4MVC 并想继续使用它。所以理想情况下,我只想将生产中的“http://mysite”替换为“http://cdnaddress/path”。有人试过吗?会不会有什么坑?

4

1 回答 1

4

在 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;
}

您应该能够通过调整此代码来实现您想要的。

于 2011-09-04T04:43:17.057 回答