Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Preventing same cookies twice
Message
 
 
To
All
General information
Forum:
ASP.NET
Category:
Other
Title:
Preventing same cookies twice
Environment versions
Environment:
C# 5.0
OS:
Windows 10
Database:
MS SQL Server
Miscellaneous
Thread ID:
01638282
Message ID:
01638282
Views:
47
Hi everybody,

I'm trying to go to the root of the problem. We're creating an ASP.NET MVC application.

I see the following code
DateTime expirationDate = DateTime.Now.AddMinutes(lockTime);

            System.Web.HttpCookie timeoutCookie = new System.Web.HttpCookie(
                SysManagerConstants.AUTH_TIMEOUT_COOKIE_KEY,
                expirationDate.ToLongTimeString());

            timeoutCookie.Expires = expirationDate;

            timeoutCookie.Path = "/";

            filterContext.HttpContext.Response.Cookies.Add(timeoutCookie);
Under certain scenarios I'm getting an error (when I am debugging the code) that the filterContext can not be modified after it was being sent.

I am not sure how to prevent this situation, e.g. that code executing in some sort of a loop.

So, the idea is to prevent this situation of appending something when the context already sent.

Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Next
Reply
Map
View

Click here to load this message in the networking platform