0

I have a common assembly where I put a lot of my helper functions etc. I want to create a common EmbeddedResourceController (kind of like WebResource.axd was for WebForms) which all my HTML helpers can use to embed and display their scripts and styles. The problem is, I need to be able to create an include path from my HTML helper code in a project agnostic way (ie without knowing any of the routing/controller rules in that project).

Ideally, I want to create an include like <script type="text/javascript" src="/EmbeddedResource/myJsScript.js"></script> from the helper code and have it work in every project that uses my common dll.

4

2 回答 2

0

也许您可以使用 HTML 帮助程序扩展。看看Bell 先生在以下问题Populate a Razor Section From a Partial中的回答

于 2012-11-03T20:17:20.347 回答
0

If I understand your question correctly, you can just use this EmbeddedResource controller as a base for a controller in each of your projects:

EmbeddedResourceController : EmbeddedResourceBase

Where EmbeddedResourceBase lives in your common dll

于 2012-10-30T19:44:35.490 回答