I am new to android and creating an app that communicate to server through web-service. Server side code is written in asp.net, and server side is maintaining Session. I am Using Volley to call the web-service but the problem i am not able to maintain the session on the server side, as far as i know i have to get the session id from the header i have searched allot on this website but i am not able to succeed.My Problem is to maintain the session throughout the app. Below is my code for calling web-service in android.
_Login_Webservice = new JsonObjectRequest(Request.Method.GET,
_Login_Url, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
// Log.e(Utils.tag, "response :" + response);
User _User;
button.setLoadingState(false);
try {
boolean Success = response.getBoolean("Success");
if (Success == true) {
//my code
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.e("", "exception in Login User Login_Activity: ");
Log.e("", "error is : " + error.toString());
}
}) {
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<String, String>();
return params;
}
};
// _Login_Webservice.setRetryPolicy(new DefaultRetryPolicy(5000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
// Adding request to request queue
Volley_Controller.getInstance().addToRequestQueue(_Login_Webservice,
Config.VOLEY_TAG);
and the response in the header is below.
{X-AspNet-Version=4.0.30319, X-Android-Selected-Transport=http/1.1, Vary=Accept-Encoding, Date=Thu, 07 Apr 2016 08:26:23 GMT, X-Android-Received-Millis=1460017311847, Set-Cookie=ASP.NET_SessionId=obzjppign5twglksjesm24wi; path=/; HttpOnly, Content-Type=text/JSON; charset=utf-8, X-Powered-By=ASP.NET, X-Android-Response-Source=NETWORK 200, Server=Microsoft-IIS/7.5, X-Android-Sent-Millis=1460017311678, Cache-Control=private}
i need value of ASP.NET_SessionId= and also need to send this in other web-services in header. Right now the response that i am receiving is below
{"Success":false,"Info":"Object reference not set to an instance of an object."}