ToPostUrl() full uri not working as expected when deployed

In development I can call
new VerifyEmail() { VerifyToken = dto.VerifyToken }.ToAbsoluteUri()
and ill get back

However when deployed to Azure I only get

Is there some settings that are stopping the deployed code from generating a full uri?
ps I’m running ServiceStack in DotNet Core not sure if that will make any difference.

In all other AppHost’s (where the HttpContext is not available as a singleton) except for classic ASP.NET you need to pass in the IRequest, e.g:

var url = new VerifyEmail { VerifyToken = dto.VerifyToken }.ToAbsoluteUri(req);

Otherwise if this is outside the context of a request you’ll need to append the BaseUrl manually, e.g:

var url = baseUrl.CombineWith(new VerifyEmail {VerifyToken = dto.VerifyToken}.ToUrl());

I was assuming that if code is working correctly in Development via vs2017 and iisexpress it should result in the same output in production?

Trying to get a handle on any potential gotcha’s for the code is deployed.

If you ever need to resolve a URL you need to pass the IRequest unless it’s available as a Singleton.

In .NET Core you can register HttpContextAccessor but it incurs a perf hit:

services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();

I get what you are saying but it doesn’t answer why when i call

new VerifyEmail() { VerifyToken = dto.VerifyToken }.ToAbsoluteUri() 

it returns https://localhost:44306/VerifyEmail?verifyToken=0b37caae650c46c3ad317aaf81795561

this happens only in dev via iisexpress and not in production, based on what you are saying it shouldn’t be returning https://localhost:44306/ in the uri at all in dev?

The solution is to always pass IRequest in. Do this for anything that needs access to the current IRequest. ServiceStack has no way to access the current IRequest unless it’s passed in or it’s available via a singleton. I can’t be any clearer, if you want consistent behavior always pass IRequest or manually concatenate the base url yourself as shown above.

Why it’s different, could be your dev iisexpress version could have IHttpContextAccessor pre-configured by default. If you read the link in my previous comment it says it used to be registered by default but has since been removed.