We have a project that uses multiple domains (with tenants) and when we need to generate an absolute url we used to do this:
var forgotUrl = Url.Action("Forgot", "Account", null, this.Request.Url.Scheme);
That worked well, and sometimes you need absolute urls when for instance sending out emails with reset password links.
However, we have now implemented SSL with reverse proxy, meaning that this.Request.Url.Scheme
no longer gives us the correct domain.
Therefore we have to do something like this instead
var forgotUrl = CurrentHostWithSchemeWithoutTrailingSlash + Url.Action("Forgot", "Account");
To simplify we have made an extension method, like so
Url.AbsoluteAction("Forgot", "Account", *data*)
And that all works like expected, so everything is well, however, you can still mess upp by writing a line calling the original Url.Action
and sending in this.Request.Url.Scheme
.
So my question is simply: Is there any way of blocking usage of that, either hiding it, or giving compiler errors, warnings, anything?