C
C#3y ago
Pokey

❔ Url.ActionLink is generating full URLs, not relative ones

I am using @Url.ActionLink("ActionName", "ControllerName", new { Route = "values" }) in my .cshtml views to generate links which I then put into the src of img tags and video players. After deploying my application and placing it behind a proxy, Url.ActionLink is generating full, non-relative URLs with the protocol and hostname. This is not at all what I want to achieve, I need those paths to be relative. According to all known laws of aviation, there is no way a bee... https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.urlhelperextensions.actionlink?view=aspnetcore-6.0 the method should only produce a full URL if the Host and Protocol parts are provided. As you can see, they are not, and when inspecting the method in my IDE it says the default values for these parameters is null. How can I stop ActionLink from generating full URLs?
UrlHelperExtensions.ActionLink Method (Microsoft.AspNetCore.Mvc)
Generates an absolute URL for an action method, which contains the specified action name, controller name, route values, protocol to use, host name, and fragment. Generates an absolute URL if the protocol and host are non-null. See the remarks section for important security information.
2 Replies
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server