title: Using Javascript files from a Class Library in an ASP.NET MVC project
body: <p>Say I have a Class Library containing a HelloWorld.js file.</p>
  <p>This file contains a couple javascript functions, like say:</p>
  <pre><code>function Hello_alert() {
     alert(&quot;Hello World!!&quot;);
  }
  </code></pre>
  <p>and</p>
  <pre><code>function Hello_console() {
     console.log(&quot;Hello World!!&quot;);
  }
  </code></pre>
  <p>I want to make so I can <strong>access the functions inside the HelloWorld.js file individually</strong>, on an <strong>ASP.NET MVC</strong> page, say, the Index.cshtml inside the Home folder. (Failing that, I'd be happy just accessing the .js file at all.)</p>
  <p>I have already changed the .js as EmbeddedResource and added it to the Assembly as such:</p>
  <pre><code>[assembly: WebResource(&quot;JSLibrary.Scriptss.HelloWorld.js&quot;, &quot;application/x-javascript&quot;)]
  </code></pre>
  <p>; referenced the DLL on my MVC project, and the DLL namespace shows up on Intellisense so I'm guessing it's linked right.</p>
  <p>Now, I've been googling incessantly the whole day, and I've found a <a href="https://www.codeproject.com/Articles/196727/Managing-Your-JavaScript-Library-in-ASP-NET" rel="nofollow noreferrer">solution that kinda does what I need</a>, but it's for <strong>Web Forms</strong>, using Page.ClientScript to register the scripts into the page itself, which allows one to call the functions inside the .js file on that page. This is pretty much what I'm trying to do, except I need it in <strong>MVC</strong>, which doesn't use the &quot;Page&quot; class like that.</p>
  <p>The closes equivalent I've found has something to do with bundles, but I couldn't find any tutorials that I could viably follow.</p>
  <p>So again, my question is, how do I somehow register Javascript files from a DLL in order for me to be able to call them from an <strong>ASP.NET MVC</strong> project?</p>
  <p><em><strong>--------Update:---------</strong></em></p>
  <p>Following the tutorial I linked above, my DLL has a class with a method that is used to register the scripts in a Script Manager, that it receives as a parameter. Like so</p>
  <pre><code>public static void includeHelloWorld(ClientScriptManager manager)
      {
          manager.RegisterClientScriptResource(typeof(JSLibrary.JSAccess), ScriptPath_HelloWorld);
      }//JSLibrary being the DLL namespace and JSAccess being the class
  </code></pre>
  <p>Then, in the main project, using <strong>Web Forms</strong>, you can call that method and pass it the ClientScript property of the current Page, where the scripts get registered, I assume. Like so:</p>
  <pre><code>protected void Page_Load(object sender, EventArgs e)
      {
          JSLibrary.JSAccess.includeHelloWorld(Page.ClientScript);
      }
  </code></pre>
  <p>I've tried it and it works on <strong>Web Forms</strong>. I need the equivalent of the Page.ClientScript in <strong>MVC</strong>, that I can send to the method in the DLL that takes in a ClientScriptManager.</p>
  <p>Thanks</p>