从 .ashx 调用 GetWebResourceUrl

发布于 2024-08-06 04:36:39 字数 375 浏览 1 评论 0原文

是否可以从 .ashx 处理程序获取 Web 资源?我们在类库中有资源(图像),并且希望从 ashx 处理程序引用它们。通常,您可以通过执行以下操作来获取 url:

Page.ClientScript.GetWebResourceUrl(this.GetType(), "myimagename");

但是,就我而言,我们有 IHttpHandler 和类库(不是 Web 应用程序)中的资源。在Web应用程序中,有一个.ashx指向类库中的IHttpHandler。

在IHttpHandler中,没有Page,也没有ClientScriptManager。如何从 .ashx 处理程序的上下文中获取 Web 资源的 url?

谢谢!

Is it possible to get a web resource from an .ashx handler? We have resources (images) in a class library and would like to reference them from an ashx handler. Normally you get the url by doing something like:

Page.ClientScript.GetWebResourceUrl(this.GetType(), "myimagename");

But, in my case we have the IHttpHandler and the resources in a class library (not the web app). In the web app, there is an .ashx that points to the IHttpHandler in the class library.

In the IHttpHandler, there is no Page and no ClientScriptManager. How can one get the url to a web resource from the context of an .ashx handler?

Thanks!

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

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

发布评论

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

评论(1

优雅的叶子 2024-08-13 04:36:39

我只需创建一个新的页面对象就可以让它工作

Page p = new Page();
p.ClientScript.GetWebResourceUrl(typeof(MyHandler), "myimagename");

I was able to get this to work just by making a new Page Object

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