我試圖訪問正在運行的系統進程使用這段代碼,它工作得很好,並顯示所有正在運行的進程,但之後當我從Visual Studio 2012發佈這個程序時,它並沒有顯示進程,但一個空白頁,,我已經禁用了Windows和病毒防火牆也不過隨後也它不工作....試圖訪問系統正在運行的進程
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Processes</title>
<script language="javascript" type="text/javascript">
window.onload = BoomBoom;
function BoomBoom() {
//var prodId = 1;
var Soap_a = "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body><HelloWorld xmlns=\"http://tempuri.org/\"></HelloWorld></soap:Body></soap:Envelope>";
var xhr = new XMLHttpRequest();
xhr.open("POST", "WebService.asmx", false);
xhr.setRequestHeader("Content-Type", "text/xml;charset=utf-8");
xhr.setRequestHeader("Content-Length", Soap_a.length.toString());
xhr.setRequestHeader("SOAPAction", "\"http://tempuri.org/HelloWorld\"");
xhr.send(Soap_a);
var xmlDoc = xhr.responseXML;
var resultNodee = xmlDoc.getElementsByTagName("HelloWorldResult");
var result = resultNodee[0].childNodes[0].data;
document.getElementById("resu").innerHTML = result;
//alert(result);
/*.childNodes[0].data;
alert(result);*/
return result;
}
</script>
</head>
<body link="red">
<div id="resu"></div>
</body>
</html>
webservice.asmx文件... <%@ WebService的語言= 「C#」 代碼隱藏= 「〜/ App_Code/WebService.cs」Class =「WebService」%>
webservice.cs file ..
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Diagnostics;
/// <summary>
/// Summary description for WebService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class WebService : System.Web.Services.WebService {
String s1;
public WebService() {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public string HelloWorld() {
foreach (System.Diagnostics.Process winProc in System.Diagnostics.Process.GetProcesses())
{
s1 = s1 + String.Format("<font size=3 face=verdana color=red></br><a href=killprocess.htm?code={0}>{0}</a></font>", winProc.ProcessName.ToString());
}
return s1;
}
}
我已經使用「killprocess.htm」頁面來停止任何正在運行的進程。
是實際打到服務器的ajax調用? – ManyRootsofAllEvil
在firefox中運行控制檯時顯示....主線程上的同步XMLHttpRequest已棄用,因爲它對最終用戶的體驗有不利影響。更多幫助http://xhr.spec.whatwg.org/user.htm:10 TypeError:xmlDoc爲空 – Deepanshu