- URL Rewriting: Ok. It might not really be a .NET thing and IIS thing but unfortunately .NET doesn't run on Apache. Features that apache's mod_rewrite has been providing for so long are still difficult to achieve in IIS.
- SetMaxAge for caching: Unfortunately, whatever value I set, it sets it to Zero. Refer to http://msmvps.com/blogs/omar/archive/2006/08/02/cache-control-header-cannot-be-set-properly-in-asp-net-2-0-a-solution.aspx
- Removing a cookie from Cache: I thought it would be easy enough!!! Just set expiry of the cookie to a past date and you should be fine! In fact, I needed to remove all the cookies starting with "custom". The way I went ahead is...
HttpCookieCollection cookies = Request.Cookies;
for(int i=0; i<cookies.Count; i++) {
HttpCookie cookie = cookies[i];
if(cookie.Name.StartsWith("custom") {
cookie.Expiry = DateTime.Now.AddYears(-1);
}
}
- seems cool? No. turns out that if you modify cookies in Request, it doesn't help. You have a Response.Cookies collection as well. Unless you add a cookie to Response collection, it won't be sent to client and hence client will not know you changed the cookie. Anyways, I added a couple of statements to add cookies in Response collection. Then, another problem. When you add a cookie to Response collection, it gets added to Request collection as well!!! Another issue. So, as many people suggest, I had to take another variable cookieCount before the loop to avoid an endless loop! What a waste of time for simple Cookie manipulation that was so easy in languages such as PHP, ASP etc. etc.
All this has been forcing me to re-think my strategy and look back at PHP, ASP or Ruby on Rails to get sanity back to development as most of the front-ends have actually moved to HTML and JS and these languages just handle the server side manipulation. Wait for a few more days and you might see me changing my framework to PHP!!!
No comments:
Post a Comment