How to get @Url.Action url in a separate script file?
By FoxLearn 2/16/2024 9:31:22 AM 260
This post shows you How to get @Url.Action url in a separate script file
@section Scripts{ <script type="text/javascript"> var app = app || {}; app.Urls = app.Urls || {}; app.Urls.baseUrl = '@Url.Content("~")'; app.Urls.addEditUrl = '@Url.Action("AddEdit")'; app.Urls.getListUrl = '@Url.Action("GetList")'; </script> <script src="~/js/external.js"></script> }
In your javascript file, you can easily get url from @Url.Action in ASP.NET or ASP.NET Core as shown below.
var url = app.Urls.getListUrl
I hope you you can solve the problem jquery url action in external js file
- How to Handle Button Clicks Using jQuery
- How to convert string into number in Javascript
- How to get datatype in JavaScript
- How to convert string to boolean in Javascript
- How to fix 'Fetch request to https:www.google.com fails with CORS'
- How to Check Internet Connection Status in Javascript
- How to download file using JavaScript
- How to get selected option in JQuery
Categories
Popular Posts
Material Lite Admin Template
11/14/2024
Freedash bootstrap lite
11/13/2024
RuangAdmin Template
11/17/2024
Responsive Animated Login Form
11/11/2024