base.Request.GetBaseUrl() is sometimes returning gateway://

I do call some services via gateway.send() and I’m not completely sure when or why this occurs but sometimes the call to GetBaseUrl() is returning gateway:// rather than the host name.

My use case is I need the access to the hosted url to allow an email or sms with a proper url to come back to particular end point or page. If there is a better way to do this that would be great.

Hi @kev_rm ,

What kind of project are you using? Is it a Blazor server application? An InProcessServiceGateway is used by BlazorServerUtils.cs which might explain why you are seeing this. Alternatively you should be able to use HostContext.Config.WebHostUrl, but it will depend if this is using the InProcessGateway. If it is, you are likely better to get this kind of info from a populated IAppSettings instance you have configured.

It is not a blazor application, its just an ASPNET core app running as an azure web app.

That’s used for in process ServiceGateway requests, you can inspect Request.OriginalRequest to get the HttpRequest if it was invoked from an HTTP Context, I.e. not a background thread or MQ request.

1 Like