Getting rid of hardcoded strings in JavaScript with ASP.NET MVC

前端 未结 1 1303
温柔的废话
温柔的废话 2021-01-15 04:54

We have a few problems in a project I am working on, where we have a lot of JavaScript files, where we have hardcoded URLs to controller actions.

  1. Hardcoded UR
1条回答
  •  粉色の甜心
    2021-01-15 05:30

    In your case you need to pass urls to js code files from views with using url helpers. Modify your js files to use one of module pattern.

    First way - importing of global variables:

    js

    (function (url) {
        // your code 
    }(external_url));
    

    view

    
    
    

    0 讨论(0)
提交回复
热议问题