No you can't put ASP.NET in a javascript file. Javascript files are static resources which should be directly served by your web server. They should never contain any server side language. You could define url
as a global variable in the view:
<script type="text/javascript">
var url = '<%= Url.Action("Action", "Controller") %>';
</script>
then use this url
variable in your javascript file.
Notice tough that depending on what you are doing with this variable there might be much better ways. For example let's suppose that in your view you have an anchor that you want to ajaxify:
<%: Html.ActionLink("some text", "actionName", new { id = "fooAnchor" }) %>
Then in your javascript you could:
$(function() {
$('#fooAnchor').click(function() {
$('#result').load(this.href);
return false;
});
});
So no need of declaring any variables at all. Another option is to define a javascript function which takes parameters so that you can pass it whatever you need.
Conclusion: think of your javascript files as reusable components that tomorrow you might plug into your cool site based on Java Servlets for example and host them on a CDN. You could even try to convert them to reusable jQuery plugins. Don't try to mix it with server side languages as it leads to a strong coupling, ugly code - tag soup.