我需要通過位於localhost的php文件傳遞一些值。我需要通過Windows Mobile 6應用程序打開該網址。請給我一個簡單的方法來做到這一點。 網址類似於:在Windows Mobile中訪問url 6
http://localhost/wlchr/index.php?data=Pharmacy&num=1
問候。
P.S
我試過連接管理器,但它給出了錯誤; 「 」名稱'ConnMgrMapURL'在當前上下文中不存在「
我需要通過位於localhost的php文件傳遞一些值。我需要通過Windows Mobile 6應用程序打開該網址。請給我一個簡單的方法來做到這一點。 網址類似於:在Windows Mobile中訪問url 6
http://localhost/wlchr/index.php?data=Pharmacy&num=1
問候。
P.S
我試過連接管理器,但它給出了錯誤; 「 」名稱'ConnMgrMapURL'在當前上下文中不存在「
我已經解決了我的問題。
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;
namespace wlchrUrl
{
class urlConn
{
public void DoConnect(string url)
{
Uri uri = new Uri(url);
try
{
HttpWebRequest httpRequest = (HttpWebRequest)HttpWebRequest.Create(uri);
HttpWebResponse httpResponse = (HttpWebResponse)httpRequest.GetResponse();
Stream stream= httpResponse.GetResponseStream();
httpResponse.Close();
stream.Close();
}
catch(Exception ex)
{
throw ex;
}
}
}
}
首先,爲了能夠回答本地主機請求,您必須實現一個Web服務器。
其次,你的web服務器必須實現URL解析來拆分URL和params。
下面是一個例子http://www.hjgode.de/wp/2012/10/19/windows-mobile-a-simple-web-server-with-extended-features/但你並沒有真正說明你的意圖,以便能夠使用
http://localhost/wlchr/index.php?data=Pharmacy&num=1
我不知道,如果上述artcle適合您的需求。
第三:ConnMgrMapURL不是任何標準Compact Framework運行時的一部分。有一個在http://msdn.microsoft.com/en-us/library/bb840031.aspx
本地ConnMgr API在MSDN描述C#的implentation使用HttpWebRequest的方法進一步閱讀有關ConnMgr http://www.codeproject.com/Articles/98020/Using-the-Connection-Manager
那麼,你嘗試過什麼? –
我嘗試過連接管理器,但它給出了錯誤; 「 」名稱'ConnMgrMapURL'在當前上下文中不存在「 – YasithLokuge
什麼連接管理器?你的C#代碼連接到URL在哪裏? –