我想将静态内容移动到CDN。但我喜欢(爱?)T4MVC并想继续使用它。理想情况下,我想在生产中将“http:// mysite”替换为“http:// cdnaddress / path”。有人尝试过吗?可能有任何陷阱吗?
答案 0 :(得分: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;
}
您应该可以通过调整此代码来实现您想要的目标。