IIS6 中 ASP.NET 中的静态 *.JS 文件的 Application_BeginRequest?

发布于 2024-08-03 14:28:36 字数 444 浏览 1 评论 0原文

我正在尝试做一些看似简单的事情:确保为发送到我的 IIS6 网站的每个静态 *.JS URL 调用 Application_BeginRequest,无论底层文件是否存在。

在 IIS6 和 IIS6 上执行此操作的好方法是什么? ASP.NET 3.5,理想情况下不会导致所有静态文件都通过 ASP.NET——只有 .JS URL?

如果您好奇为什么,我正在使用一个现有的应用程序,该应用程序使用 Application_BeginRequest 进行自定义重定向和路径重写。以这种方式实现它并不是我的第一选择,但鉴于现有的内容,我也想将其扩展以覆盖 .JS,而不是包含另一种不同的重定向/重写方法(例如 IIS 重定向配置、重写模块等) .) 这可能会使应用程序的部署和测试变得复杂,尤其是在 IIS6 上。

我知道这里的 IIS7 故事要好得多(特别是围绕配置、模块等的 XCOPY 部署),但我现在无法升级此应用程序。

I'm trying to do something seemingly simple: ensure that Application_BeginRequest is called for every static *.JS URL sent to my IIS6 website, whether or not the underlying file exists.

What's a good way to do this on IIS6 & ASP.NET 3.5, ideally without causing all static files to go through ASP.NET-- only the .JS URLs?

If you're curious about why, I'm working with an existing app that uses Application_BeginRequest to do custom redirection and path rewriting. It woudln't have been my first choice to implement it this way, but given what's there I want to extend it to cover .JS too, instead of including another different redirection/rewrite method (e.g. IIS redirection configuration, a rewrite module, etc.) which may complicate deployments and testing of the app, especially on IIS6.

I know the IIS7 story here is much, much better (esp. around XCOPY deployment of configuration, modules, etc.), but I can't upgrade this app right now.

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

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

发布评论

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

评论(1

猥︴琐丶欲为 2024-08-10 14:28:36

我尚未对此进行测试,但在 IIS 管理器中,在站点属性上单击“主目录”选项卡,然后单击“配置 - 添加映射到 aspnet_isapi 的 .js 扩展名”。确保取消选中“验证文件存在”复选框。您可能需要尝试其他选项。

I haven't tested this, but in IIS Manager, on the properties of your site click the Home Directory tab, and click configuration - add a .js extension that maps to aspnet_isapi. Make sure you uncheck the "Verify file exists" checkbox. You might need to play around with the other options.

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