I've written the following code in Console. I want to display the string the code returns, on my Layout.cshtml page like any other things on the page. How can I do it using Web API?
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string serverName = "localhost";
var nsm = new ServerManager();
using (Microsoft.Web.Administration.ServerManager sm = Microsoft.Web.Administration.ServerManager.OpenRemote(serverName))
{
//site mySite = sm.Sites.Add("Racing Cars Site", d:\inetpub\wwwroot
acing", 8080);
int counter = 1;
foreach (var site in sm.Sites)
{
//var p = site.Bindings.GetCollection().GetAttribute("physicalPath");
var p = site.Applications[0].VirtualDirectories[0].PhysicalPath;
int b=0;
foreach (Microsoft.Web.Administration.Binding binding in site.Bindings)
b= binding.EndPoint.Port;
Console.Write(String.Format(CultureInfo.InvariantCulture
, "Site number {0} : , {1} PhysicalPath : {2} , Port:{3} {4} "
, counter.ToString(), site.Name ,p , b, Environment.NewLine));
counter++;
}
Console.ReadKey();
}
}
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…