I am working on a .net core application where I need the application path to the virtual directory. I do not want the physical path, I want it in form of url like:
http://www.mywebsite.com/mydirectory
I have tried with Request.Host but it only gives me http://www.mywebsite.com without the virtual directory path.
Any help on this appreciated!
You can use the IUrlHelper to resolve the base-path of the application. If the application is not hosted within a virtual directory the returned path is just empty...
IUrlHelper url = ...
string virtualDirectory = url.Content("~");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With