ルートディレクトリを取得するURLは、例えばhttp://localhost:51898


 
public static string GetRootURI()
{
string AppPath = "";
HttpContext HttpCurrent = HttpContext.Current;
HttpRequest Req;
if (HttpCurrent != null)
{
Req = HttpCurrent.Request;

string UrlAuthority = Req.Url.GetLeftPart(UriPartial.Authority);
if (Req.ApplicationPath == null || Req.ApplicationPath == "/")
// Web
AppPath = UrlAuthority;
else
//
AppPath = UrlAuthority + Req.ApplicationPath;
}
return AppPath;
}