public static class CacheUtils { private static readonly Cache cache = HttpRuntime.Cache; /// <summary> /// Gets data from cache public static Object GetFromCache(string key) { return cache[key]; } public static void InsertIntoCache(string key, int cacheTimeInMinutes, Object obj) { cache.Insert(key, obj, null, DateTime.Now.AddMinutes(cacheTimeInMinutes), Cache.NoSlidingExpiration, CacheItemPriority.Normal, OnRemove); } public static void OnRemove(string key, object cacheItem, CacheItemRemovedReason reason) { //log.Info("Object removed from cache: Key-" + key + ": Reason-" + reason); } public static void RemoveFromCache(string key) { cache.Remove(key); } }
Monday, 28 January 2013
storing values in cache memory(Not sessions not applications)
Sunday, 27 January 2013
Reverse a string and sentence Linq Query
A string Reverse
string yString = "String to reverse";
string rString = yString.Reverse().ToString();
Sentence reverse with each word in it...
string rString = string.Join(" ",from s in yString.Split(' ') select new String(s.Reverse().ToArray()));
Monday, 14 January 2013
Reg Expressions validator imp list
Email : "^([0-9a-zA-Z]([-\.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$"
Only Numbers With Decimal : "^[0-9]*\.?[0-9]+$"
Alphanumeric only : "^[a-zA-Z0-9]*$"
Numbers with length between 2 to 5 Ex : "^([0-9]{2,5})$"
Numbers with Exact lenght(Example 5) : "^(\d{5})$"
Friday, 2 November 2012
File Upload Max Lenght exeeded Error
The default setting for thr file upload control is 4MB we can overwrite in web.config.
If you are using IIS7 use both else maxRequestLength is enough.
In system.web
<httpRuntime maxRequestLength="1048576" executionTimeout="3600" />
And in system.webServer
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1073741824" />
</requestFiltering>
</security>
IMPORTANT: Both of these values must match. In this case, my max upload is 1024 megabytes.
maxRequestLength has 1048576 KILOBYTES, and maxAllowedContentLength has 1073741824 BYTES.
I know it's obvious, but it's easy to overlook.
Wednesday, 3 October 2012
Create fake certificate in IIS 6
Every time I need to enable https / ssl for a development or staging server I spend 30 minutes googling for instructions. Now I'm blogging just to remind myself how it's done:
Install the IIS 6 Resource Kit referenced at:
http://support.microsoft.com/kb/840671 from:
http://www.microsoft.com/downloads/details.aspx?FamilyID=56fc92ee-a71a-4c73-b628-ade629c89499
Obtain the site Id of the website you want to install the certificate for by clicking on the Web Sites major heading in the left hand side of the IIS admin tool and view the "Identifier" on the right hand side for whichever site you need. This is the site ID. further instructions at: http://weblogs.asp.net/owscott/archive/2005/07/29/421058.aspx
Run the following command replacing www.example.com with the host header of your site and 123456 with the site id obtained in the previous step (the /V:365 indicates that the certificate should be valid for 365 days, adjust accordingly):
Install the IIS 6 Resource Kit referenced at:
http://support.microsoft.com/kb/840671 from:
http://www.microsoft.com/downloads/details.aspx?FamilyID=56fc92ee-a71a-4c73-b628-ade629c89499
Obtain the site Id of the website you want to install the certificate for by clicking on the Web Sites major heading in the left hand side of the IIS admin tool and view the "Identifier" on the right hand side for whichever site you need. This is the site ID. further instructions at: http://weblogs.asp.net/owscott/archive/2005/07/29/421058.aspx
Run the following command replacing www.example.com with the host header of your site and 123456 with the site id obtained in the previous step (the /V:365 indicates that the certificate should be valid for 365 days, adjust accordingly):
"C:\Program Files\IIS Resources\SelfSSL\selfssl.exe" /T /N:CN=www.example.com /V:365 /S:123456
Wednesday, 19 September 2012
Monday, 17 September 2012
Sitecore Google Maps Add in for 6.0 and 6.1
Nice Description for the google maps add in in site core.........
Subscribe to:
Posts (Atom)