C
C#17mo ago
TheHitchhiker

❔ 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
TheHitchhiker17mo ago
basically i am mapping ImageName to hostname/ImageName any other way to do that?
x0rld
x0rld17mo ago
that ? HttpContext.Request.Host.Host
TheHitchhiker
TheHitchhiker17mo ago
x0rld
x0rld17mo ago
why youy have string.empty ?
TheHitchhiker
TheHitchhiker17mo ago
i want to replace it with hostname
x0rld
x0rld17mo ago
why you don't have access to it ?
TheHitchhiker
TheHitchhiker17mo ago
like that https://localhost:3000/pictures/image.jpg
Relevant
Relevant17mo ago
What type of application is this?
TheHitchhiker
TheHitchhiker17mo ago
web api
Relevant
Relevant17mo ago
But you're not in a controller, because this is your automapper config, I assume
TheHitchhiker
TheHitchhiker17mo ago
yes i said "i have no access to HttpContext.Current.Request.Url.Host"
Relevant
Relevant17mo 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
TheHitchhiker17mo ago
its just string ig
x0rld
x0rld17mo ago
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
TheHitchhiker17mo ago
why not?
Relevant
Relevant17mo 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
Accord17mo 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
More Posts