Michael Sterling
asked on
How do I do a simple POST and GET in C# to pass/retrieve values?
I'm used to being able to use session variables or (in an older application) the authentication provided by ASP .NET to control security/access within my web app. Now, for a couple of reasons, I need to POST and GET data between pages but I'm struggling with how this is done. I need a simple way,using C#, to POST some data from one page and then GET (process/retrieve) it on another page. Can someone provide me with simple clear examples or code for how this is done? I'm using VS 2012 and 2015.
ASKER
@HainKurt: Website is on a server farm. How do I assign to those hidden vars in C#?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I'm hosting the site on GoDaddy. I'm using a my sequel database.
ASKER
I tried using session variables on the server farm, and they would never maintain their values in between pages.
what product are you using, please send me GoDaddy farm product...
you should set them to use same session...
maybe add a sql server to the farm or use same web config...
or use sticky sessions somehow...
the other solution is really pain!
I mean write web app without session :)
you should set them to use same session...
maybe add a sql server to the farm or use same web config...
or use sticky sessions somehow...
the other solution is really pain!
I mean write web app without session :)
ASKER
Understood, but I did not create or design GoDaddy webfarm. I am stuck in this situation, and not able to use session-variables at all. Albeit a pain, I really need to know how to post a response to a page, and retrieve it using a GET. Do you have any examples of that?
I gave you how to do that in my first post...
you can post to a page, but you cannot get it if page re-send it back :)
you can use cookies, but it is not secure...
can I get the link to GoDaddy farm product...
you can post to a page, but you cannot get it if page re-send it back :)
you can use cookies, but it is not secure...
can I get the link to GoDaddy farm product...
ASKER
Sure you want the link to my website? On GoDaddy?
ASKER
How do I assign a value to the hidden Field, in C#?
godaddy farm product... I did not see it here
https://ca.godaddy.com/hosting/windows-hosting#compare
https://ca.godaddy.com/hosting/windows-hosting#compare
aspx
c#
js
jQuery
<asp:HiddenField id="userid" value="" />
c#
userid.value="HainKurt";
js
alert(document.getElementById("<%=userid.ClientId%>").value);
jQuery
alert($("#<%=userid.ClientId%>").val());
ASKER
Ok. i don't need to use runat="server"?
neither did I when I checked their business plans https://ca.godaddy.com/hosting/business-hosting
So what plan do you have?
So what plan do you have?
:) yes of course, I forgot to add runat="server" part
I really I would not go to sessionless hosting solution!
you should somehow enable use sessions...
without sessions, it will be nightmare to build any web site :)
you should somehow enable use sessions...
without sessions, it will be nightmare to build any web site :)
ASKER
I've called into customer support and have been told that they don't allow session variables in a server farm. when you think about it, it makes sense, because you're not always going to return to the same server.
ASKER
I've tested the hidden field and I'm still not getting any value / empty string. In my default.aspx page (my login page) I set my hidden field value as such:
Then when I go to the landing page, after the login, I check for the value like this and get nothing:
HiddenField hf = (HiddenField)this.Master.FindControl("hdfldTest");
hf.Value = dbr["UserStatus"].ToString();
Then when I go to the landing page, after the login, I check for the value like this and get nothing:
HiddenField hf = (HiddenField)this.Master.FindControl("hdfldTest");
string temp = hf.Value.ToString();
when you think about it, it makes sense, because you're not always going to return to the same server.
but, in farm, there is a load balancer which allocates sessions to servers...
it can be adjusted to use sticky session, ie, same guy always hit on same server...
what product did you get? I never saw godady/farm hosting :)
I need to see whats going om...
if you create a test login and provide url then I can check...
if you create a test login and provide url then I can check...
ASKER
I got one of the hosting packages on their "Plesk" hosting platform. I don't have access to the load balancer to set it to use sticky sessions. Also, changing that setting for me would change it for all of their users. I don't think they're going to do that.
ASKER
HainKurt, check your inbox
ok, what should I do here to reproduce the issue?
ASKER
the error is behind the scenes. i guess this way wont work.
I see lots of errors left and right...
http://test.sjushtracker.com/Reports.aspx?UserStatus=ADMIN
should be
http://test.sjushtracker.com/LoadStudents.aspx?UserStatus=ADMIN
http://test.sjushtracker.com/Reports.aspx?UserStatus=ADMIN
Line 199: oMail.Body = TESTING PHASE + <br/> + ltReport.Text;
should be
oMail.Body = "TESTING PHASE<br/>" + ltReport.Text;
http://test.sjushtracker.com/LoadStudents.aspx?UserStatus=ADMIN
Line 205: cmd = Utility.AddNewStudentRecord;
Compiler Error Message: CS0117: 'Utility' does not contain a definition for 'AddNewStudentRecord'???
ASKER
Ok. i'm working on those issues but they don't affect the fact that my hidden variables are not passing between pages.
on which page do you have hidden vars?
ASKER
My master page is where they were. I don't have them now.
ASKER
thanks for your help and patience
normally, you add hidden vars into forms
Open in new window
then on target page
Open in new window