I am new to android and am creating an application that communicates with the server through a web service. The server side code is written in asp.net, and the server side maintains the session. I use Volley to call a web service, but the problem is I can’t support the server side session, as far as I know, I need to get the session ID from the header that I have searched on this website, but I can’t succeed. My problem is to maintain a session throughout the application . Below is my code for calling a 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 answer is in the header 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 the value ASP.NET_SessionId = , and also send it to other web services in the header. Right now the answer I get is below
{"Success":false,"Info":"Object reference not set to an instance of an object."}
android session android-volley
zafar Apr 08 '16 at 9:44 2016-04-08 09:44
source share