Last post Aug 12, 2015 08:49 PM by jkjhse
Aug 12, 2015 10:30 AM|Radhesham Khatri|LINK
I Have a question which is very related to my last thread. but I decided to start a very new thread to clear my concepts which I have before in PHP.
I used to use sessions in such a way which restrict user from inappropriate actions.
I want to ask you that, in php i start a SESSION by calling this function
But Q1: what is the way to start and end session in asp.net Web pages?
In php Whenever a i try to redirect a Page using session in if by this code:
it always did work for me.
Q2: What should I use here in php in place of header to redirect it to the destination?
I hope someone have better steps of guidance for me.
Aug 12, 2015 11:13 AM|PatriceSc|LINK
Q1: Assuming you are talking about session variables (rather than user session from a security point of view), in ASP.NET, the session is just available if enabled. And the session id will be fixed once you stored your first session variable.
The session ends automatically when the user doesn't hit the site for 20 minutes (this is a default). See
https://msdn.microsoft.com/en-us/library/ms178581.aspx for details.
Q2: Seems unrelated to session but to just check if a submit button was posted to the page. Use Response.Redirect to go to another page (which likely does nothing else than sending a location header).
Don't compare too much PHP and ASP.NET. You have a whole Framework so even if the underlying principles are the same it could be likely done quite differently in ASP.NET.
If you were talking rather about authentication you have a whole part of ASP.NET to handle this for you with likely a quite steep learning curve but allowing to easily have this done to focus rarther on business needs once familiar with it.
Aug 12, 2015 12:00 PM|Radhesham Khatri|LINK
I am very new here at asp.net and trying to learn things which comes in my experience on daily basis.
as before i worked with php thats why i did show a similarity with asp.net in my question.
IT means for redirecting i should only use response.redirect method than whatever i use in my conditions whether it is a session like
if (Session["SessionName"] != null && Session["SessionRole"]=="Super Admin")
or simple IsPost?
Is header is php function or a part of html?
Aug 12, 2015 08:49 PM|jkjhse|LINK
The code above should work. Instead of checking !=null in every page just write the null check in _PageStart.cshtml in root.
if (Session["SessionName"] != null)