In external js file, I cant use
url = "@Url.Action("Action", "Controller")"
//url output : @Url.Action("Action", "Controller")
//I get IllegalPath Name error.
When I write like this:
url = "/Controller/Action"
And If project is under a sub folder, then scripts do not work. I need something like this as relative Url:
url = "~/Controller/Action"
How can ı do this? Thanks.
As .js files are not parsed by asp.net mvc view engine, you simply cannot use any c# code in there. I would suggest using unobtrusive approach, something like this
And in javascript, use value of
data-request-url