I'm a developer of both IOS (novice) and ASP.NET. Now I have a problem with such kinds of issue.
My IPhone application try to connect to a ASP.NET website, then sends login and password my method GET, of course, via HTTP Request. Then C# on the server will treat the request, which code is as follows:
-----------------------
string userName = (string)Request["UserName"];
string password = (string)Request["Password"];
var userIdRes = usersAdapter.VerifyLogin(userName, password);
if (userIdRes.Count == 1)
{
Session["CurrentUserId"] = userIdRes[0].Id;
Response.Write("1");
}
else
{
Response.Write("0");
}
Response.Flush();
Response.End();
-----------------------------
So once the login succeed, A session is opened for my client IPhone. Just after login, my Objective C sends the next HTTP Request for getting a list, which is treated by the following C# server program in another method:
-----------------------------
if (Session["CurrentUserId"] == null)
{
Response.Write("ERROR: SESSION EXPIRED");
return;
}
//Do anything else......
<div></div>
--------------------------
Here is my problem. Session["CurrentUserId"] was just set a value a few seconds ago by the first program, but here it is reported to be null and my IPhone application receive each time the string from ASP.NET server "ERROR: SESSION EXPIRED"
What is strange is that, this problem never happens when I simulate the same HTTP request via a normal web browser of any type (IE, Firefox, Safari...), it works perfectly, this problem seems to occor only on my IPhone native application
in Objective C.
I understand that the ASP.NET use cookie automatically. Here
the ASP.NET server seems to create a new Session each time my IPhone application send a HTTP request ? Is there anyone who knows how to do so that my application IPhone can profit the Session like a web browser ?
alfred_shi
0 Points
1 Post
Why ASP.NET doesn't keep Session for my IPhone native application ?
Jul 15, 2012 12:41 PM|LINK
Hello,
I'm a developer of both IOS (novice) and ASP.NET. Now I have a problem with such kinds of issue.
My IPhone application try to connect to a ASP.NET website, then sends login and password my method GET, of course, via HTTP Request. Then C# on the server will treat the request, which code is as follows:
-----------------------
string userName = (string)Request["UserName"];
string password = (string)Request["Password"];
var userIdRes = usersAdapter.VerifyLogin(userName, password);
if (userIdRes.Count == 1)
{
Session["CurrentUserId"] = userIdRes[0].Id;
Response.Write("1");
}
else
{
Response.Write("0");
}
Response.Flush();
Response.End();
-----------------------------
So once the login succeed, A session is opened for my client IPhone. Just after login, my Objective C sends the next HTTP Request for getting a list, which is treated by the following C# server program in another method:
-----------------------------
if (Session["CurrentUserId"] == null)
{
Response.Write("ERROR: SESSION EXPIRED");
return;
}
//Do anything else......
<div></div>--------------------------
Here is my problem. Session["CurrentUserId"] was just set a value a few seconds ago by the first program, but here it is reported to be null and my IPhone application receive each time the string from ASP.NET server "ERROR: SESSION EXPIRED"
What is strange is that, this problem never happens when I simulate the same HTTP request via a normal web browser of any type (IE, Firefox, Safari...), it works perfectly, this problem seems to occor only on my IPhone native application in Objective C.
I understand that the ASP.NET use cookie automatically. Here the ASP.NET server seems to create a new Session each time my IPhone application send a HTTP request ? Is there anyone who knows how to do so that my application IPhone can profit the Session like a web browser ?
Mudasir.Khan
All-Star
15346 Points
3142 Posts
Re: Why ASP.NET doesn't keep Session for my IPhone native application ?
Jul 15, 2012 04:26 PM|LINK
i guess there is a problem with the cookies and iPhone, so server is not isn't able to get back the seessionID
roopeshreddy
All-Star
20155 Points
3328 Posts
Re: Why ASP.NET doesn't keep Session for my IPhone native application ?
Jul 15, 2012 04:42 PM|LINK
Hi,
Is cookies enables in the Settings of iPhone? If not, try enabling it and try again!
Hope it helps u...
Roopesh Reddy C
Roopesh's Space