T4MVC 通过 CDN

发布于 2024-12-02 23:22:18 字数 117 浏览 0 评论 0原文

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

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? Could there be any pitfalls?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

橙幽之幻 2024-12-09 23:22:18

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

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文