firefox only
相容IE,請參考: DOMParser for IE and Safari
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
[ServiceContract]
public interface ITestService
{
[OperationContract]
void DoWork();
[OperationContract]
string GetLogFilePath();
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.ServiceModel.Activation;
using System.Web;
[ServiceBehavior]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class TestService : ITestService
{
public void DoWork()
{
}
public string GetLogFilePath()
{
string logFile = "~/res/iislog/100/ex07021023.log.gz";
return HttpContext.Current.Server.MapPath(logFile);
}
}
string url="http://www.365articles.com/modules.php?name=Your_Account";
string data="username=gogo&user_password=newnewne&op=login";
byte[] buffer=Encoding.UTF8.GetBytes(data);
string result="";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "POST";
req.ContentType ="application/x-www-form-urlencoded";
req.ContentLength = buffer.Length;
//req.Proxy = new WebProxy(proxy, true); // ignore for local addresses
req.CookieContainer = new CookieContainer(); // enable cookies
Stream reqst = req.GetRequestStream(); // add form data to request stream
reqst.Write(buffer, 0, buffer.Length);
reqst.Flush();
reqst.Close();
Console.WriteLine("\nPosting data to " + url);
HttpWebResponse res = (HttpWebResponse)req.GetResponse(); // send request,get response
Console.WriteLine("\nResponse stream is: \n");
Stream resst = res.GetResponseStream(); // display HTTP response
StreamReader sr = new StreamReader(resst);
result=sr.ReadToEnd();
using(System.IO.StreamWriter writer=new StreamWriter("C:\\Temp\\checkcheck.html"))
{
writer.Write(result);
}
$('#role').html($(this).children("[@selected]").text()).show();