I have my website path using HttpRuntime.AppDomainAppPath (e.g. this is C:/personal/Website/page.aspx )
The web service is always located on the parent page.aspx passport of the parent folder (for example, C:/personal/Service/service.asmx ). I get the webservice path using ABC.dll in the servicePath variable, like this line servicePath="C:/personal/Service/service.asmx" .
How to check the path to the service on the way to the website?
If (GetWebPath()== GetServicePath()) { // ... do something } private string GetWebPath() { string path = HttpRuntime.AppDomainAppPath; string[] array = path.Split('\\'); string removeString = ""; for(int i = array.Length; --i >= 0; ) { removeString = array[array.Length - 2]; break; } path = path.Replace(@"\" + removeString + @"\", ""); return path; } private string GetServicePath() { string path = @"C:\MNJ\OLK\ABC.asmx" string[] array = path.Split('\\'); string removeString = ""; for(int i = array.Length; --i >= 0; ) { removeString = @"\" + array[array.Length - 2] + @"\" + array[array.Length - 1]; path = path.Replace(removeString, ""); break; } return path; }
source share