return a js file from asp.net mvc controller

Posted by Erwin on Stack Overflow See other posts from Stack Overflow or by Erwin
Published on 2010-04-03T17:23:04Z Indexed on 2010/04/03 17:33 UTC
Read the original article Hit count: 528

Filed under:
|
|
|

Hi all fellow programmer

I'd like to have a separate js file for each MVC set I have in my application

/Controllers/
    -TestController.cs
/Models/
/Views/
    /Test/
        -Index.aspx
        -script.js

And I'd like to include the js in the Index.aspx by

<script type="text/javascript" src="<%=UriHelper.GetBaseUrl()%>/Test/Js"></script>

Or to put it easier, when I call http://localhost/Test/Js in the browser, it will show me the script.js file

How to write the Action in the Controller? I know that this must be done with return File method, but I haven't successfully create the method :(

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about return