Using @Url.Action() in views does not work if the site is behind a reverse proxy that is terminating TLS. Anywhere that JavaScript is relying on an ASP.NET URL it should be modified to the URL is computed in the Controller using a system setting rather than on-the-fly in the View's JavaScript. Here's a pattern in controllers that can be followed:
var baseUri = await GetBaseUriBuilderAsync();
baseUri.Path = Url.Action(nameof(WhateverController.Method), WhateverController.Name);
viewModel.WhateverUri = baseUri.Uri;
Then in the JavaScript:
const whateverUrl = new URL('@Model.WhateverUri .AbsoluteUri');
Using
@Url.Action()in views does not work if the site is behind a reverse proxy that is terminating TLS. Anywhere that JavaScript is relying on an ASP.NET URL it should be modified to the URL is computed in the Controller using a system setting rather than on-the-fly in the View's JavaScript. Here's a pattern in controllers that can be followed:Then in the JavaScript: