From the DLL that is called by the C # .NET web application, how do you find the base URL of the web application?
Will this work?
HttpContext.Current.Request.Url
UPDATE:
To get the base url you can use:
HttpContext.Current.Request.Url.GetComponents(UriComponents.SchemeAndServer, UriFormat.Unescaped)
If this is an assembly that non-web projects can reference, you may not need the System.Web namespace.
I would use the DannySmurf method.
, HttpContext.Current.Request.Url, http://:
HttpContext.Current.Request.Url.GetComponents(UriComponents.HostAndPort, UriFormat.Unescaped);
Assembly.GetExecutingAssembly(), DLL.
Server.MapPath, FullPath , .
, , :
string _baseUrl = String.Empty; HttpContext httpContext = HttpContext.Current; if (httpContext != null) { _baseURL = "http://" + HttpContext.Current.Request.Url.Host; if (!HttpContext.Current.Request.Url.IsDefaultPort) { _baseURL += ":" + HttpContext.Current.Request.Url.Port; } }
Source: https://habr.com/ru/post/1698192/More articles:Multiple forms per page HTML pages for yourself - htmlHow to enable the default Visual Basic.NET namespace? - vb.netHow to find out which enums are defined by a class? - javaКнопка прогресса для Windows Forms - .netHow to use the queue library in SML / NJ - queuePHP-based handheld applications - phpHow can I search for questions from a script? - pythonWhich wiki will allow me to dynamically create a page when I click on a link? - coredumpDetermining software quality? - qaEclipse Abstract Tree Syntax Programmatic Access - javaAll Articles