There are many older examples with this kind of syntax (from the question):
Here's a typical example of what you should never do:
<script type="text/javascript"> $.ajax({ url: '/home/index' }); </script>
and here's how this should be done:
<script type="text/javascript"> $.ajax({ url: '@Url.Action("index", "home")' }); </script>
Running an ASP.NET MVC app from a virtual directory in IIS7
I then found UrlHelper configuration is more difficult than in previous versions of MVC,
Are the Url Action methods "gone" or not what should be used now? Does Core want URL rewriting? How do I create a dynamic url string in Core 1.1 for JavaScript the "Core" way? I could build it manually and pass it to my View, but that is not what I wanted to do.
(no jQuery please, and yes I know the question above has jQuery)
Edit: In my JavaScript I have,
var xhr;
xhr = new XMLHttpRequest();
var url = //this is what I want Asp.Net to generate. Currently I manually build it within the JavaScript. It should be,
var url = 'Home/Index' //this can change possibly depending on where the application is deployed.
I have tried this:
@UrlHelper url = new UrlHelper(HttpContext.Current.Request.RequestContext)
var url = '@url.Action("index", "home")';
It does at the first Razor code with:
"The name 'UrlHelper' does not exist in the current context"
I can probably figure this part out (I have tried it with the full namespace as well). My main question is if this is still the right way to do things in Core. It seemed it might not be so which is when I stopped and asked here. I thought I was missing something.