@ Url.Action does not work in javascript file [closed]

0

From a view razor I can call links with this

window.location = '@Url.Action("ReporteDictaminaciones", "Auditoria")' + '?Auditor=' + auditor

Passing it to a JavaScript file stops working.

Any Solution?

    
asked by LoganFenix 13.04.2018 в 19:04
source

1 answer

1

One solution (not the most precious one) would be to save the content in a variable within the view and then use it in the js file.

Code in the view:

<script type="text/javascript">
    var myURL = '@Url.Action("ReporteDictaminaciones", "Auditoria")' + '? Auditor=' + auditor;
</script>

Code in js file:

function () {
   alert(myURL);
}

The opposite of this is that you have to define this variable in all the views that use the js file (or the function in question).

    
answered by 16.04.2018 / 23:01
source