❔ 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
basically i am mapping
ImageName
to hostname/ImageName
any other way to do that?that ? HttpContext.Request.Host.Host
why youy have string.empty ?
i want to replace it with hostname
why you don't have access to it ?
like that
https://localhost:3000/pictures/image.jpg
What type of application is this?
web api
But you're not in a controller, because this is your automapper config, I assume
yes
i said "i have no access to HttpContext.Current.Request.Url.Host"
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
its just string ig
maybe with that ?
https://stackoverflow.com/questions/39864550/how-to-get-base-url-without-accessing-a-request
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...
why not?
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>()
...
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.