Wednesday, December 21, 2011

Changing .net Target Framework



I just faced one issue today i migrated my website from asp.net 3.5 framework to asp.net 4.0 but after that i was getting errors and wanted to switch back but i silly me that i had not taken any backup of the previous version. So after exploring around i got the
solution .......

Tuesday, December 20, 2011

Hiding Partitions


Many times we want to hide some files or hide a drive suppose e:\ as that data is crucial or we don't want to share this data with others so what can we do in this case.
There is a way out in Group Policy editor steps:
1) Open Group policy editor by clicking on Start >>run >>gpedit.msc
2) On extreme left pane click on administrative templates under User Configuration
3) Click on windows component then windows explorer
4) Double Click on Hide These Specified Drives In My Computer.
5) Under setting tab click on enable Choose the drive & hide that drive
isn't that Simple enough that anyone can do this .
To make the drive visible double click on Hide These Specified Drives In My Computer and disable it out .

Create Your Personal Log on Message


Create Your Personal Log on Message
To create a message for your windows log on try this trick.
1. Start >> Run type regedit and the click OK.
2. In the Registry Editor, find the following key:
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
3. Double click on LegalNoticeCaption, type something like My Personal Log on Message and then click OK.
4 Double click LegalNoticeText, and then type your log on message.
5. Close the Registry editor and your new message will appear at every log on.
Note:
For Standalone networks or Work groups or Personal Computers the custom screen appears just before the Welcome screen.

Can you create a folder without name is this possible...


yes it is we can create a folder without any name it seems very tempting isn't it . to do this there are just 2 steps to follow yes just 2 steps OK let us see


1) Create a folder while renaming the folder delete the name of the folder.
2) Press Alt+255 click enter

you would see a folder without any name nice na....

Monday, December 19, 2011

One Click Computer Lock..


I know it seems interesting if somebody says we can lock your system with just a single click, so how to go about it. I have 2 options if you people have any other please let me know i will be glad to add this on the blog. ok about this the first method


you can either create a short cut on your desktop or write a simple command on your run command is


"%Windir%\system32\rundll32.exe user32.dll,LockWorkStation"

How about creating a short cut
1) Rightclick on your desktop you will see new >> Shortcut
2) on this window you need to type the command
"%Windir%\system32\rundll32.exe user32.dll,LockWorkStation"
click on next
3) type the desired name you like for this shortcut click on finish
4)click on this shortcut to test.


now comming on the simplest way the second way

i know this would be much much simpler than the previous one

Use windows Key from Keybord with L

i.e. Win+L your desktop would be locked .......

Tips for creating a folder named con.


It seems really simple creating a folder in windows OS but hay try to create a folder right now but the twist is to create the folder with name CON try it were you successful i know if you are trting this with the help of GUI(graphical user interface) its really hard yes there is a bug in windows os if you are trying to create a folder named as CON you wont be successful.


So what can we do to create this folder we can create this folder in CUI(character User Interface) or using command prompt.
Try these steps :

1) click on start >> run
2) on run type CMD & click ok
3) you will see a black prompt window
3) type Mkdir \\.\c:\
4) to remove this directory you can type rmdir \\.c:\con

Difference between DML DDL DCL and TCL?




DML:

DML is abbreviation of Data manipulation Language. It is useed to work with the data of the tables.

Basic Statements: SELECT, UPDATE, INSERT, delete statements.

DateTime Functions


To get current date

SELECT GETDATE()

To get yesterday

SELECT DATEADD(d,-1,GETDATE())

Saving changes is not permitted in SQL 2008 Management Studio?



I recently started using SQL Server 2008, at first it was really nice, but then I started getting a weird error every time I tried modifying a table.

"Saving changes is not permitted. The changes you have made require the following tables to be dropped and re-created. You have either made changes to a table that can’t be re-created or enabled the option Prevent saving changes that require the table to be re-created."

Row Data Bound Event and how to use it

Row Data Bound Event and how to use it :


Control Used :Grid View 
Event Under Grid View :onrowdatabound



Error 'System.Web.UI.WebControls.GridView' does not have a public property named 'SortedAscendingCellStyle'.

Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. 

Parser Error Message: Type 'System.Web.UI.WebControls.GridView' does not have a public property named 'SortedAscendingCellStyle'.

Source Error: 



Line 91: <RowStyle BackColor="White" ForeColor="#003399" />
 Line 92: <SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
 Line 93: <SortedAscendingCellStyle BackColor="#EDF6F6" />
 Line 94: <SortedAscendingHeaderStyle BackColor="#0D4AC4" />
 Line 95: <SortedDescendingCellStyle BackColor="#D6DFDF" />

Saturday, December 17, 2011

Intermittent Invalid Viewstate Error in ASP.NET Web pages

Error:
The issue presents itself with and error similar to this:
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\mdcr\5c7639a0\5981344d\App_Web_oja12imh.0.cs Line: 0 

Stack Trace: 


[FormatException: Invalid character in a Base-64 string.]
System.Convert.FromBase64String(String s) +0
System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +77
System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String serializedState) +4
System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter, String serializedState) +37
System.Web.UI.HiddenFieldPageStatePersister.Load() +113




[ViewStateException: Invalid viewstate. 
Client IP: known ip
Port: Port number XX
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; InfoPath.3; .NET4.0C; .NET4.0E)
ViewState: /wEPDwUKMTY5ODYyNzkxNQ9kFgICAw9kFgICAQ9kFgJmD2QWAmYPZBYEZg9kFgICAQ88KwAJAQAPFgYeDVNlbGVjdGVkSW5kZXgCDR4IRGF0YUtleXMWAB4LXyFJdGVtQ291bnQCDmQWHGYPZBYCAgEPDxYIHghUYWJJbmRleAEAAB4EVGV4dAUMTm90aWZpY2F0aW9uHgtDb21tYW5kTmFtZQUETW92ZR4PQ29tbWFuZEFyZ3VtZW50BQEwZGQCAQ9kFgICAQ8PFggfAwEAAB8EBQkxLkNvbXBhbnkfBQUETW92ZR8GBQExZGQCAg9kFgICAQ8PFggfAwEAAB8EBRMyLlR5cGUgb2YgT3duZXJzaGlwHwUFBE1vdmUfBgUBMmRkAgMPZBYCAgEPDxYIHwMBAAAfBAUUMy5FbXBsb3ltZW50IFNvdXJjZXMfBQUETW92ZR8GBQEzZGQCBA9kFgICAQ8PFggfAwEAAB8EBRU0LlN0YXRpc3RpY3M6IEN1cnJlbnQfBQUETW92ZR8GBQE0ZGQCBQ9kFgICAQ8PFggfAwEAAB8EBRQ1LkVtcGxveWVlczogQ3VycmVudB8FBQRNb3ZlHwYFATVkZAIGD2QWAgIBDw8WCB8DAQAAHwQFFzYuU3RhdGlzdGljczogTmV3IEhpcmVzHwUFBE1vdmUfBgUBNmRkAgcPZBYCAgEPDxYIHwMBAAAfBAUZNy5TdGF0aXN...]


Cause : 
There are many reasons for this error :

  1. Web Farm or server cluster.
  2. Form Posts
  3. Application pool recycling 
  4. Proxy servers and virus scanners
Resolution :

  1. Use specific machine key in your web config. we can use these tools Link 1 or Link 2. Sample Key Node:

    <machineKey validationKey=”56AB7132992003EE87F74AE4D9675D65EED8018D3528C0B8874905B51940DEAF6B85F1D922D19AB8F69781B2326A2F978A064708822FD8C54ED74CADF8592E17″
    decryptionKey=”A69D80B92A16DFE1698DFE86D4CED630FA56D7C1661C8D05744449889B88E8DC”
    validation=”SHA1″ decryption=”AES”
    />
  2. Post to the same aspx page.
  3. Turn off the firewall and antivirus software.
  4. Adjust the settings on the application pools so that recycling is less likely to occur at peak periods.


Thursday, December 15, 2011

How to remove all asp.net data cache by c#


Introduction :
Cache feature is a great feature in asp.net. By caching we store data in memory for quick access. As Microsoft eloquently puts it, "Caching is a technique widely used in computing to increase performance by keeping frequently accessed or expensive data in memory. In the context of a Web application, caching is used to retain pages or data across HTTP requests and reuse them without the expense of recreating them."

But many times we want to update our cache for new updates to happen so to remove data cache from memory. the code snippet given below can be used to remove data cache from memory :

Method One :
foreach (DictionaryEntry dCache in HttpContext.Current.Cache)
{
   HttpContext.Current.Cache.Remove(dCache.Key.ToString());
}

Method Two :

IDictionaryEnumerator cacheEnumerator = HttpContext.Current.Cache.GetEnumerator();

while (cacheEnumerator.MoveNext())
{
  HttpContext.Current.Cache.Remove(cacheEnumerator.Key.ToString());
}

We need these two namespaces to perform this task as Generics is used

using System.Collections;
using System.Collections.Generic;


Conclusion:
These methods are used to remove data cache from memory it won't remove other cache like output or others .....

Friday, December 9, 2011

Insufficient memory error in Visual Studio 2010



“Insufficient available memory to meet the expected demands of an operation at this time, possibly due to virtual address space fragmentation. Please try again later.”


I was getting this error on my Visual Studio 2010 while copying and pasting stuff on visual studio was really annoyed by looking as visual studio takes lot of time while doing this. I tried lots and lots of ways but no good. I even tried to search on google but there was a little about this error and then i found the answer on microsoft website which had a hot fix for this bug. Scott Gu even said in his blog that this is Patch for VS 2010 Find and Replace Dialog Growing.


Title Cut or Copy displays 'insufficient memory' error in Visual Studio 2010
Release Date 6/23/2010
Size 1.65 MB
Version Hotfix
Category Build
Milestone
Description
Cut or Copy displays "insufficient memory" error in Visual Studio 2010

This is a patch from microsoft website

Download Now




Wednesday, December 7, 2011

Do i need Web Garden for more reliablity

Q. How Many Worker Processes Do I Need?
 Q. Do i need Web Garden for more reliablity?
 A.

Worker processes are a way of segmenting the execution of your website across multiple exe's. You do this for a couple of reasons, one if one of the workers gets clobbered by run time issues it doesn't take the others down. For example, if a html request comes in that causes the process to run off into nothing then only the other requests that are being handled by that one worker processor get killed. Another example is that one request could cause blocking against the other threads handled by the same worker.

As far as how many you need, do some load testing. Hit the app hard and see what happens with only one. Then add some more to it and hit it again. At some point you'll reach a point of truly saturating the machines network, disk, cpu, and ram. That's when you know you have the right balance.

Incidentally, you can control the number of threads used per worker process via the machine.config file. I believe the key is maxWorkerThreads.

Now, beware, if you use session, Session state is not shared between worker processes. I generally recommend avoiding session anyway but it is something to consider.


For all intents and purposes you might consider each worker process as it's own separate web server. Except they are running on the same box.

 Creating a Web garden for an application pool can also enhance performance in the following situations:
• Robust processing of requests: When a worker process in an application pool is tied up (for example, when a script engine stops responding), other worker processes can accept and process requests for the application pool.
• Reduced contention for resources: When a Web garden reaches a steady state, each new TCP/IP connection is assigned, according to a round-robin scheme, to a worker process in the Web garden. This helps smooth out workloads and reduce contention for resources that are bound to a worker process.

 For even greater reliability, you can configure an application pool to be supported by multiple worker processes. An application pool that uses more than one worker process is called a Web garden. The worker processes in a Web garden share the requests that arrive for that particular application pool. If a worker process fails, another worker process can continue to process requests. 

A process serving application pool suffered a fatal communication error with the Windows Process Activation Service.

Why does Application Pool Crashes Sometimes?
I was getting this error on my server

Log Name:      Application
Source:        Application Error
Date:          12/6/2011 3:57:47 PM
Event ID:      1000
Task Category: (100)
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      XXX
Description:
Faulting application name: w3wp.exe, version: 7.5.7601.17514, time stamp: 0x4ce7a5f8
Faulting module name: KERNELBASE.dll, version: 6.1.7601.17651, time stamp: 0x4e211319
Exception code: 0xe053534f
Fault offset: 0x0000b9bc
Faulting process id: 0x%9
Faulting application start time: 0x%10
Faulting application path: %11
Faulting module path: %12
Report Id: %13
Event Xml:

 
   
    1000
    2
    100
    0x80000000000000
   
    73326
    Application
    XXX
   
 
 
    w3wp.exe
    7.5.7601.17514
    4ce7a5f8
    KERNELBASE.dll
    6.1.7601.17651
    4e211319
    e053534f
    0000b9bc
 

and after this i usually get an error


"A process serving application pool 'XXX' suffered a fatal communication error with the Windows Process Activation Service. The process id was '1234'. The data field contains the error number."





I am running an ASP.NET Framework 3.5 under integrated environment web application on IIS 7.5 on Windows Server 2008 R2.Sometimes i get this error  When access to the website, it raise error message: ‘HTTP Error 503. The service is unavailable.’.

I am still working on this issue and got some temporary measures that delay this error
measures taken under Application pool advanced settings changed the settings :
1)   Maximum worker processes to 2 and made it a Web Garden
2)  Changed the Rapid failed protection Failure interval to 2
3)  And lastly changed the Recycling regular time interval from 1740 (default) to 1000.

since that time its working properly but for a quick measure when you are facing this issue
 go to the Internet Information Services (IIS) Manager to recycle my Application Pool again. it would work properly .

What is webgarden and Application Pool?


Question -> What is webgarden and Application Pool?
Answer.
Webgarden ->A Web garden is configured on a single server by specifying multiple worker processes for an application pool.

Application Pool ->An Application Pool can contain one or more applications and allows us to configure a level of isolation between different Web applications. For example, if you want to isolate all the Web applications running in the same computer, you can do this by creating a separate application pool for every Web application and placing them in their corresponding application pool. Because each application pool runs in its own worker process, errors in one application pool will not affect the applications running in other application pools. Deploying applications in application pools is a primary advantage of running IIS 6.0 in worker process isolation mode because you can customize the application pools to achieve the degree of application isolation that you need.


Question ->Where to set webgarden in IIS?
Answer :
1) Configuring Web Gardens with IIS 6.0
This feature of IIS 6.0 is available only when IIS is running in worker process isolation mode.
To configure a Web garden by using IIS Manager
A.
In IIS Manager, expand the local computer, expand Application Pools, right-click the application pool, and then click Properties.
B.
Click the Performance tab, and under Web garden, in the Maximum number of worker processes box, type the number of worker processes that you want to assign to the application pool. (You must type a number greater than 1 for the application pool to become a Web garden.
C.
Click OK.





2) Configuring Web Gardens with IIS 7.0 and IIS 7.5(windows server 2008   )

This feature of IIS 6.0 is available only when IIS is running in worker process isolation mode.

To configure a Web garden by using IIS Manager
A.
In IIS Manager, expand the local computer, expand Application Pools, right-click the application pool, and then click Advanced Settings.
B.
Under Process Model,in the Maximum number of worker processes box, type the number of worker processes that you want to assign to the application pool. (You must type a number greater than 1 for the application pool to become a Web garden.
C.
Click OK.


To configure a Web garden by using Adsutil.vbs
A.
In the Run dialog box, type cmd, and then click OK.
B.
At the command prompt, type:
cscript %SystemDrive%\Inetpub\AdminScripts\adsutil.vbs set W3SVC/AppPools/ApplicationPoolName/MaxProcesses n
Replace n with the number of worker processes that you want to service the application pool.