T4MVC through CDN
I want to move my static content to CDN. But I like (love?) T4MVC and want to keep using it. So ideally I want to just replace in production "http://mysite" to "http://cdnaddress/path". Did somebody try it?开发者_JAVA百科 Could there be any pitfalls?
Look for ProcessVirtualPathDefault in T4MVC.tt.settings.t4:
// 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;
}
You should be able to achieve what you want by tweaking this code.
精彩评论