HttpCookie.Expire Timezone Implications?

Jan 26, 2011

I'm trying to write cookies from my website and I'm trying to figure out what implications timezones has over the HttpCookie.Expire property. Should I be passing DateTime.Now.AddDays(1) or DateTime.UtcNow.AddDays(1) or the users's timezone plus a day?

View 1 Replies


Similar Messages:

JavaScript Date Format Without Timezone Info - Timezone Offsets?

Jul 6, 2010

I have a client side JavaScript that generates a date in JavaScript( new Date(2007,5,1)).

I need this date passed through to a hidden field that the code behind can access.

My issue is that when the hidden field is converted into a DotNet datetime, the time is incorrect. This is because the JavaScript is including timezone info from the client browser.

DotNet is then using this info to recalculate the time based on the difference between the server time and the client time.

What i need from the JavaScript is just the year, month and day.

I don't want to pass through 3 int values to my code behind as this will be a major change to the whole app.

What is the best way for me to accomplish this?

If i can set a UTC time with no timezone info I think that might work.

View 4 Replies

Web Forms :: Display Session (Timeout) Expire Message 5 Seconds Before Session Expire

May 7, 2015

Using this code i want to show an modal pop up to the user that "your session will be expired within 5 minutes , Click here [BUTTON] to reset your session" , here's my code :

<asp:Button ID="btnReset" Text="Reset" runat="server" OnClick="ResetSession" />
<br />
Your Session will expire in <span id = "seconds"></span> seconds.
<script type="text/javascript">
function SessionExpireAlert(timeout) {
var seconds = timeout / 1000;
seconds--;

[CODE]...

View 1 Replies

Implications Of Using Memorycache In Asp?

Oct 7, 2010

I've got a class that needs to store data in a cache. Originally I used it in an asp.net application so I used System.Web.Caching.Cache.Now I need to use it in a Windows Service. Now, as I understand it, I should not use the asp.net cache in a not asp.net application, so I was looking into MemoryCache. The problem is that they are not compatible, so either I change to use MemoryCache in the asp.net application, or I will need to create an adapter so ensure that the two cache implementations have the same interface (maybe derive from ObjectCache and use the asp.net cache internally?)What are the implications of using MemoryCache in an asp.net?

View 1 Replies

DataSource Controls :: Implications Of LINQ To SQL

Mar 12, 2010

I thought I'd read that LINQ to SQL performs operations on the user's behalf and acts pretty much in the same way as if you manually queried a database. I was told today that it can be considerably slower.Can anyone point me to a link or share their knowledge so I can help to build up a picture of what actually happens?

View 4 Replies

Implications Of Conflicting Versions Of System.Web.Extensions?

Feb 23, 2010

One of the libraries I am including in my project makes use of System.Web.Extensions 3.5.0.0, which conflicts with my Framework 2.0 application, which uses (C:Program FilesMicrosoft ASP.NETASP.NET 2.0 AJAX Extensionsv1.0.61025System.Web.Extensions.dll). I can think of 3 possible solutions:

Ignore the warning and don't change anything. I am not sure what the application does to handle this.
Add an assembly binding element to my web.config (see below) Configure the application explicitly to use different assemblies (I think this is possible, but don't know how to do it).

However, I am unsure of the implications of each of these decisions. The application seems to work perfectly fine even when I ignore the warnings (solution 1), but ignoring warnings that I don't fully understand bugs me...as does having warnings like this show up at all.

[URL]

View 1 Replies

MVC :: RhinoMock + Mocking The Httpcookie?

Jun 1, 2010

I have a cookie which my controller uses.

How should i mock the cookie?

View 3 Replies

What Happens When A HttpCookie Expiration Has Been Crossed

Mar 26, 2010

I am creating some cookies in my ASP.NET application. These cookies expire 10 minutes after they have been created. I follow the approach described on MSDN as shown here:[URL]

My question is, when a cookie "expires", what happens? Does the browser automatically delete the cookie? Is it our responsibility as developers to remove the cookies if they exist and have expired?

View 2 Replies

HttpCookie.HttpOnly In .NET And JavaScript?

Oct 13, 2010

A web site was developed and deployed to client. In some cases, I need to set the flag HttpCookie.HttpOnly = true. Okay - I have done it. Next question:

Is Cookie available after setting flag in JavaScript?
or maybe some restriction when I am using JavaScript?
or do I need to make some changes in existing JavaScript?

View 1 Replies

HttpCookie Is Not Deleted When Session Changes Or Is Invalid?

Jul 20, 2010

I'm creating an HttpCookie, setting only the name and value and not the expires property, then adding it to the response. Simple enough. The cookie is created (but not persisted) as expected. The problem is when the session changes for some reason (like the website was rebuilt, or I rebuilt my app when debugging) then the cookie stays around. I want the cookie to be valid for only the original session it was created on.

According to MSDN it says: "If you do not specify an expiration limit for the cookie, the cookie is not persisted to the client computer and it expires when the user session expires." I guess I don't know exactly what "session expires" encompasses. I figure the cookie gets deleted after 20 min when the session expires. But should the cookie get deleted if the session it was created on doesn't exist anymore for any number of reasons? The only time I've seen the cookie get deleted is when the user closes all browser windows and opens a new one.

If this is all true, I may have to store the original session id ("ASP.NET_SessionId") in the cookie, then check it against the current session id, if they're different, then delete the cookie or create a new one.

Here's the code (the only difference between my cookie and the one in the MSDN examples is I'm storing multiple values in the cookie):

private void SaveValuesToCookie(string[] names, string[] values)
{
HttpCookie cookie = new HttpCookie("MyCookie");
for (int i = 0; i < names.Length; i++)
{
string name = names[i];
cookie.Values[name] = values[i];
}
Response.Cookies.Add(cookie);
}
private string GetValueFromCookie(string name)
{
HttpCookie cookie = Request.Cookies["MyCookie"];
if (cookie == null)
return null;
return cookie.Values[name];
}

View 2 Replies

Implications Of Changing Column From Not Null To Nullable In Entity Framework?

Apr 1, 2011

I have to change the username column in my database to nullable, which means everywhere in my code, I now have to check username.HasValue and change references to username to username.Value. Is there anything I can do to avoid having to change all the references to username to username.Value?

View 1 Replies

SQL Server :: Implications Of Not Closing An Open Connection Declared Locally?

Oct 5, 2010

I was wondering about something. I'm supporting a .NET C# application which has a number of database connections declared locally as IDbConnection with MS SQL Server and NHibernate. These connections are declared locally and not explicitly closed after a specific operation is performed. Are these connections automatically closed after the local method is executed, or could these connections be floating around somewhere? We're having semaphore max out problems, and I'm trying to see if this may be the culprit. I'm doubtful, as I believe these connections would automatically close, but thought I'd throw out hte possibility.

View 1 Replies

Security :: FormsAuthenticationTicket And HttpCookie Are Not Working In Chrome?

Apr 30, 2010

I have a web application developed using VB .Net 2003, and is running ASP Net 1.1.

The application is running fine on all browser, except for the login/authentication control that doesn't work properly on Chrome.

We have different types of users using the website, and each user type has different menu items displayed for.

The problem is, if a user logs on with let's say Admin account, and logs off and later logs on again using student account, the user still gets the Admin menu, and of course vice versa.

I'm not sure if I'm doing something wrong, or there is something I'm missing here.

On more thing, if the timeout period reached, and the session was timed out , and the user (regardless of the type) tries to log on again, he is successful on all browser except on Chrome again!, where it keeps telling the session was timed out, and never logs on again until clearing the cookies.

This is what i have in my application web.config

<!-- Authentications -->
authentication mode="Forms">
<forms loginUrl="index.aspx" name="authCookie" protection="All" timeout="60" path="/"></forms>
</authentication>

[Code]....

View 2 Replies

C# - How To Browser Occasionally Losing HttpCookie For Authentication After Postback And Redirect

Dec 29, 2010

This has been a nagging issue for some time, but very sporadic and difficult to isolate.

From time to time, browsers that have authenticated on a web application, have been open for a while, have logged in and out of the same web application multiple times, have multiple tabs, are pretty much any browser (Chrome, IE, Firefox, Safari), and seemingly at random, lose their ability to retain an AuthCookie after being set and followed by a redirect. Closing the browser and starting a new session resolves the issue, as does opening up a different browser and attempting to authenticate.

Our team uses forms authentication for all of our websites and web application. This is a pretty typical setup where a login form is displayed, the user enters credentials and a cookie is set on the click event of the postback, then a redirect occurs to the same page where the cookie is then referenced and used to complete authentication.

In this situation

FormsAuthentication.FormsCookieName = ".WebAuth"

Within Event:

FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, Username, DateTime.Now, DateTime.Now.AddMinutes(SessionTimeout), false, Username); HttpCookie faCookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(authTicket));
Response.Cookies.Add(faCookie);
Response.Redirect(Request.RawUrl, true);
After the redirect, on PreInit:
HttpCookie authCookie = Request.Cookies[cookieName];

At this point, the authCookie variable is typically not null, but in these isolated circumstances that I've outlined above, the cookie comes back null after the redirect.

This happens very randomly, sometimes weeks before affecting one of our developers. As I said, restarting the browser resolves the issue.

Today I had it happen on our dev server while using Chrome. I had logged into the application, allowed the application to session timeout, and then attempted to login again. The attempted login then failed to set the cookie. I remotely attached Visual Studio to the process on the server to begin debugging. The entire time I could step through my code, even deploy new code versions to the server with updates, restart the app, restart IIS on the server, attach and reattach to the project, and the issue persisted in Chrome. In Firefox, I was able to authenticate without issue.

From Chrome, the login would validate, attempt to set a Response Cookie as outlined above. Prior to redirect, I could see the properly set Response Cookie, as well as its counterpart in the Request Cookies. However, on each redirect after a seemingly successful login, the Response and Request Cookie are gone.

I enabled Trace on the application to view the cookie collection:

There is a .WebAuth in the Request Cookies Collection, as well as ASP.NET_SessionId and several ASPSESSIONIDxxxxxxxx, but when the page loads, only the ASP.NET_SessionId and ASPSESSIONIDxxxxxxxx cookies are available in the Request.Cookies scope, no sign of the .WebAuth. However, in the page's Trace information after render, there multiple .WebAuth cookies listed, it is just that the page seems to have no access to them.

Primarily, on a working version after authentication there is both a .WebAuth Response and Request Cookie in the page's Trace info. But on a non functioning browser window, the Response Cookie is absent.

Has anyone else had any experience with this? It is such a nagging issue, and so sporadic, but I would love to be able to resolve it. My concern is that it may be affecting users and we would have no knowledge since the description of the issue is so convoluted.

View 1 Replies

Webforms Site Using HTTPCookie With 100 Year Timeout Times Out After 20 Minutes

Jun 11, 2010

I have a site that is using Forms Auth. The client does not want the site session to expire at all for users. In the login page codebehind, the following code is used:

// user passed validation
FormsAuthentication.Initialize();
// grab the user's roles out of the database
String strRole = AssignRoles(UserName.Text);
// creates forms auth ticket with expiration date of 100 years from now and make it persistent
FormsAuthenticationTicket fat = new FormsAuthenticationTicket(1,
UserName.Text, DateTime.Now,
DateTime.Now.AddYears(100), true, strRole,
FormsAuthentication.FormsCookiePath);
// create a cookie and throw the ticket in there, set expiration date to 100 years from now
HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName,
FormsAuthentication.Encrypt(fat)) { Expires = DateTime.Now.AddYears(100) };
// add the cookie to the response queue
Response.Cookies.Add(cookie);
Response.Redirect(FormsAuthentication.GetRedirectUrl(UserName.Text, false));

The web.config file auth section looks like this:

<authentication mode="Forms">
<forms name="APLOnlineCompliance" loginUrl="~/Login.aspx" defaultUrl="~/Course/CourseViewer.aspx" />
</authentication>

When I log into the site I do see the cookie correctly being sent to the browser and passed back up: However, when I walk away for 20 minutes or so, come back and try to do anything on the site, the login window reappears. This solution was working for a while on our servers - now it's back. The problem doesn't occur on my local dev box running Cassini in VS2008.

View 3 Replies

How To Get Timezone Before Postback

Jul 7, 2010

I am making a page that accepts post data from any number of pages that I cannot change, access, or in any way control.

I need, in one way or another, to get the timezone of the user. I know, ideally the posting page would do this, but I cannot access these pages.

First, there is javascript. I can get the javascript function to return (or change a label to) the correct value, but the problem is I need this info before the postback. I've been trying to write the timezone name on another page and read that page, but I have no idea how to begin to do that? Any other workaround to use the javascript is welcome, or any way to force call this before Page_Load is called?

[code]...

Basically, this works in debug mode, but when it's live only an empty string is returned. I am baffled? Is there any better way to read data from a page? I am using Request.ServerVariables["REMOTE_ADDR"] to get the ip, and that seems to be correct, since it inserts the correct ip into the database I'm using.

Here is the call:

GetTimezone(Request.ServerVariables["REMOTE_ADDR"]);

View 1 Replies

How To Order A TimeZone List In C#

Feb 17, 2010

I have an ASP.NET web application that requires users to select their appropriate time zone so that it can correctly show local times for events.

In creating a simple approach for selecting the time zone, I started by just using the values from TimeZoneInfo.GetSystemTimeZones(), and showing that list.

The only problem with this is that since our application is primarily targeted at the United States, I'd like to show those entries first, basically starting with Eastern Time and working backwards (West) until I reach Atlantic time.

View 2 Replies

Getting Timezone List To Combo Box?

Jan 26, 2010

I want get timezone list to combo box. How can i get timezone list?

View 9 Replies

How To Convert Timezone Conversion

May 15, 2010

How do I convert timezone from this format "03/03/2010 03:24:42 PM EST" to the current timezone in asp.net?

View 2 Replies

How Does TimeZone.CurrentTimeZone Work If Run In A Web App

Mar 25, 2011

How does TimeZone.CurrentTimeZone work if run in an ASP.NET app? Does it return the timezone of the application pool running the application? If using impersonation, does it return the timezone of the user its impersonating?

View 1 Replies

C# - Get Correct Timezone For Client?

Jul 28, 2010

To get the correct timezone of the user I get the offset first using javascript:-

var offset =new Date().getTimezoneOffset();

and then I apply assign the value to the server side variable.where I get the timezone using :-

ReadOnlyCollection<TimeZoneInfo> timeZones = TimeZoneInfo.GetSystemTimeZones();
foreach (TimeZoneInfo timeZone in timeZones)
{

[code]...

View 2 Replies

Datetime - Set TimeZone For MVC Application?

Jul 7, 2010

My Application hosted at server in time zone which differs from mine. All date in database is not correct for my time zone. How can I set my time zone for Application or how I can convert date to my time zone on output

View 1 Replies

Add A Field To Save The Timezone ?

Jan 11, 2011

I'm building an ASP web app that stores appointment times; it'll be used in different timezones. I'm currently saving an appointment in the database as a datetime field. Do I also need to add a field to save the timezone ? What's the best option to solve these multi-timezone issues?

View 1 Replies

Write A Timezone Converter Library In C#?

Jan 5, 2011

How do I write a timezone converter library in c#? or is there an existing timezone class I could use?

I will need the timezone database and be able to use it to calculate/convert from one UTC timezone to another timezone.

View 2 Replies

C# - GetUtcOffset Returning Wrong Timezone?

May 13, 2010

for some reason when I use the following code

TimeSpan timeDiffUtcServer = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now);

it returns -07:00:00 offset

I am using Windows XP and my timezone is set to Pacific time -08:00. I am running this through VS 2010's built in IIS server which is on my computer, so I can't figure out why the discrepancy in time.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved