Reputation: 85
using asp.net/c#, how is possible to :
Note that the cookie value I will set it with php. Note that the html webform is included in the code:
asp:Content ID="webform" ContentPlaceHolderID="webform1" runat="Server"
So I need a way to manipulate this webform depending of the settings of the cookie value that I will read all the time the page gets loaded
Upvotes: 0
Views: 9109
Reputation: 1827
if (!Page.IsPostback)
Call the method below, based on the return value response.redirect to another page.
private string GetCookieValue(string cookieName, string itemName)
{
var CookieName = "MY_COOKIE";
var CookieValue = string.empty;
HttpCookie myCookie = Request.Cookies[CookieName];
if (myCookie == null) return "No cookie found";
//If you added a key vs. the value in the cookie use this code
//CookieValue = myCookie[itemName].ToString();
//Get the value of the cookie if you are not using a key
CookieValue = myCookie.Value.ToString();
Return CookieValue;
}
Upvotes: 1