嵌入视图和资源 (mvc)

发布于 2024-08-26 21:05:27 字数 534 浏览 3 评论 0原文

我已在库中嵌入了多个视图,以便我可以使用此方法在项目之间重复使用,该方法工作正常:

http://www.wynia.org/wordpress/2008/12/aspnet-mvc-plugins/

但有一个视图使用 Javascript 文件。我尝试将其标记为嵌入式资源并添加它 AssemblyInfo.cs ,然后使用引用此资源

<%= ClientScript.GetWebResourceUrl(this.GetType(), "FullPath.FileName.js")%>

这实际上是在视图

WebResource.axd?d=nUxqfqAUQLabLU54W

中显示此输出我认为这是因为我试图引用嵌入式来自嵌入资源的资源。

帮助感谢我在兜圈子..

史蒂夫

I've embedded several views in a library so that I can re-use across projects using this method which works OK:

http://www.wynia.org/wordpress/2008/12/aspnet-mvc-plugins/

But one view usings a Javascript file. I've tried marking this as an embedded resource and adding it AssemblyInfo.cs and then referencing this resource using

<%= ClientScript.GetWebResourceUrl(this.GetType(), "FullPath.FileName.js")%>

This is literally displaying this output in the view

WebResource.axd?d=nUxqfqAUQLabLU54W

I think this is because Im trying to refer to an embedded resource from an embedded resource.

Help appreciated as Im going round in circles..

Steve

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

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

发布评论

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

评论(1

猫卆 2024-09-02 21:05:27

这里的问题是我对 GetWebResourceUrl 的调用。我已将格式更改为下面的格式,并且工作正常:)

<script src="<%= ClientScript.GetWebResourceUrl(typeof(Opal.Web.Shared.AClassInMyAssembly), "FullPath.FileName.js")%>" type="text/javascript"></script>

因此,我将调用包含在脚本标记中并更改了类型参数。

The problem here was with my call to GetWebResourceUrl. I've changed the format to that below and it works fine :)

<script src="<%= ClientScript.GetWebResourceUrl(typeof(Opal.Web.Shared.AClassInMyAssembly), "FullPath.FileName.js")%>" type="text/javascript"></script>

So Ive contained the call in a script tag and changed the type parameter.

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