I have a response which holds a list of self-referring URLs. So I call something like /party/1
and it will return a response with a string property for `ImageUrl’. The image URL is just a specific call back to another web service on the same host.
What is the best way to create this self-referncing URL? The best I could come up with is:
public static string GetPartyImageUrl(string party, IRequest request)
{
// build http request
string partyName = party.ToLower().Replace(" ", "_").Replace(".", "");
var imageRequest = new PartyImage() { PartyAbbreviation = partyName }.ToGetUrl();
var url = (request.IsSecureConnection ? "https" : "http") + "://" + ((HttpRequestWrapper)request.OriginalRequest).Url.Authority + imageRequest;
return url;
}
Example:
- https://www.test.com/party/1 should return a URL in it’s response for the logo
- **https://www.test.com/**party/image/x
- The bold part I need to neatly compose