ライセンスを取り消すために休憩サービスにHttpPostを実行しています。 Androidでは、リクエストは完全に機能します。上記HttpPostはC#では動作しませんが、Androidでは正しく動作します。
@Override
protected String doInBackground(String... params)
{
String request = serverUrl + "api/Public/RemoveInstall?DeviceID="+deviceId+"&UserID="+m_userID;
try {
if(!isNetworkAvailable())
{
return "no_accesToken";
}
else
{
URL url = new URL(request);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setConnectTimeout(CONNECTION_TIMEOUT);
conn.setDoOutput(false);
conn.setInstanceFollowRedirects(false);
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setRequestProperty("charset", "utf-8");
conn.setConnectTimeout(1500);
conn.setUseCaches(false);
conn.connect();
...
}
コード:C#でのポストを行う場合でも、私は応答
を取得アンドロイドで
「は、何のアクションも要求に合致するコントローラ上では見られませんでした」完全に動作しますが、C#では動作しません:
public async Task<bool> RevokeLicenseAsync(string userId)
{
if (!IsInternetConnected())
{
errorMsg = "No internet connection";
return false;
}
string deviceId = GetDeviceID();
var postData = new List<KeyValuePair<string, string>>();
postData.Add(new KeyValuePair<string, string>("DeviceID", deviceId));
postData.Add(new KeyValuePair<string, string>("UserID", userId));
//the header arguments "ContentType" and "ContentLength are filled in automatically"
var formContent = new FormUrlEncodedContent(postData);
if (!String.IsNullOrEmpty(token))
{
using (HttpClient httpClient = new HttpClient())
{
httpClient.BaseAddress = new Uri(serverUrl);
using (var response = await httpClient.PostAsync("api/Public/RemoveInstall",formContent))
{
もう一つは、あなたがURLでいますが、体内でそれを投稿秒1のパラメータを投稿アンドロイド要求では代わりにGET –
の、デバイスID = 'POSTで'持っています。最初のものが機能する場合は、2番目のものについても同じ操作を行います。 – Nkosi
ああ、私はそれを見ておかなければなりません – PrisonMike