❔ How to get hostname string ?

i need the hostname string in MappingProfile for automapper i have no access to HttpContext.Current.Request.Url.Host so how can i do that?
17 Replies
TheHitchhiker
TheHitchhikerOP2y ago
basically i am mapping ImageName to hostname/ImageName any other way to do that?
x0rld 👻 🎃
that ? HttpContext.Request.Host.Host
TheHitchhiker
TheHitchhikerOP2y ago
x0rld 👻 🎃
why youy have string.empty ?
TheHitchhiker
TheHitchhikerOP2y ago
i want to replace it with hostname
x0rld 👻 🎃
why you don't have access to it ?
TheHitchhiker
TheHitchhikerOP2y ago
like that https://localhost:3000/pictures/image.jpg
Relevant
Relevant2y ago
What type of application is this?
TheHitchhiker
TheHitchhikerOP2y ago
web api
Relevant
Relevant2y ago
But you're not in a controller, because this is your automapper config, I assume
TheHitchhiker
TheHitchhikerOP2y ago
yes i said "i have no access to HttpContext.Current.Request.Url.Host"
Relevant
Relevant2y ago
And if you were creating a console application, that would indeed be true Anyways, not sure if that's possible. Doesn't really make sense for automapper to be able to handle that
TheHitchhiker
TheHitchhikerOP2y ago
its just string ig
x0rld 👻 🎃
Stack Overflow
How to get base url without accessing a request
How to get the base URL in AspNet core application without having a request? I know from the Request you can get the scheme and host (ie $"{Request.Scheme}://{Request.Host}" would give something l...
TheHitchhiker
TheHitchhikerOP2y ago
why not?
Relevant
Relevant2y ago
Stack Overflow
Automapper: passing parameter to Map method
I'm using Automapper in a project and I need to dynamically valorize a field of my destination object. In my configuration I have something similar: cfg.CreateMap<Message, MessageDto>() ...
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise 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