【问题标题】:T4MVC through CDNT4MVC 通过 CDN
【发布时间】:2011-09-04 12:43:17
【问题描述】:

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

【问题讨论】:

  • t4mvc 与此无关。
  • @Daniel,真的吗? T4MVC 生成我的“强类型”静态链接

标签: asp.net-mvc t4mvc


【解决方案1】:

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

你应该能够通过调整这段代码来实现你想要的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-07-07
    • 2017-03-04
    • 2019-01-15
    • 1970-01-01
    • 1970-01-01
    • 2011-04-18
    • 1970-01-01
    • 2016-09-12
    相关资源
    最近更新 更多