Skip to content

Ensure URI construction in Ops JavaScript is using the new pattern #695

@k7hpn

Description

@k7hpn

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');

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions