Is there any way that I could include a javascript file that is an embedded resource of an assembly in my Views for MVC 3?
I have tried to create an Action that gets the embedded resource from the assembly and then returns a FileStreamResult like so...
public FileStreamResult Scripts()
{
System.Reflection.Assembly myassembly;
myassembly = System.Reflection.Assembly.GetExecutingAssembly();
System.IO.Stream file =
myassembly.GetManifestResourceStream("Testing.testscript.js");
return File(file, "application/x-javascript");
}
Then in my master view:
<script type="text/javascript">
@Html.RenderAction("Scripts")
</script>
This doesn't seem too work.
I would rather just be able to get the embedded resource as a link and then use that as my src value for the script. So something like:
<script src="@Html.GetEmbeddedResourceAsLink("Testing.testscript.js")"/>
Anyone know how?
This doesn't seem too work.Why? What error are u getting?