Saturday, February 20, 2010

How to remove all the cache object from asp.net application

Cache object in .NET technologies very power full feature and we all use it for increasing out application performance. In one of my project i need to remove all of the my cache once some task was completed. So i have done some digging and i have found some beautiful way of removing all the cache object. As you know cache it self is dictionary entry object so we can always remove them via loop here are some of code examples from which we can remove the all the cache object.

//Following namespace you need.
using System.Collections;
using System;
using System.Collections.Generic;
using System.Web;

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

while (cacheEnumerator.MoveNext())
{
HttpContext.Current.Cache.Remove(cacheEnumerator.Key.ToString());
}
Here is the another example of removing cache.
foreach (DictionaryEntry dEntry in HttpContext.Current.Cache)
{
HttpContext.Current.Cache.Remove(dEntry.Key.ToString());
}
Please make sure this is way only for the cache object it will not going to remove other cache like output cache etc.



kick it on DotNetKicks.com
Shout it
Share:
Thursday, February 4, 2010

Microsoft Community Techdays at Ahmedabad- A great Event

On 30th January Microsoft,Pass Organization and Ahemdabad .NET User Group organized Microsoft Community Techdays. It was a great event and full of information. There were five session with the full of content. First session was given by Mahesh Dhola on the Windows Azure Platform. In his session he explained all the thing related with windows azure platform from basics like what is windows azure why it is required and what is use of windows azure platform and how its works.

Windows Azure presentation by Mahesh Dhola

Insight of Windows Azure Platform by Mahesh Dhola

The next session was presented by Pinal Dave- A Microsoft Most Valuable Professional and Well know Database Architect for SQL Server. It was about SQL Azure. He has explained what is SQL Azure and all the tools that are needed to connect and maintain database on SQL Azure Server.

PICT0015

SQL Azure: Extending SQL Data Platform to Cloud By Pinal Dave

Then after lunch there was session given by Jadeja Dushyantsinh on Silvelight 4.0. In this session he has explained what is Silvelight, History of Silvelight and what’s new in Silvelight 4.0.The session also include some interesting demo of Silvelight 4.0 Features.

PICT0029

Microsoft Silvelight 4.0- An Overview By Dushyantsinh Jadeja

After this session there was an interesting session by Jacob Sebastian A well know SQL Book writer and Microsoft Most Valuable Professional . He explained SQL Server 2008 R2 data migration features and integration with Visual Studio 2010 by taking an example of love story of Summit- A DBA and Leena-A Developer. It was a great session We have learnt lots of refracting features available in SQL Server 2008 R2 and Visual Studio 2010 Ultimate.

PICT0038

Fall in love with SQL Server 2008 R2 By Jacob Sebastian

Last but not least session given by Prabhjot Bakshi – A well known Microsoft Certified Trainer about Visual Studio 2010 enhancement for Developers. In this session he has explained UML Designer features and lots of new things about Microsoft.NET 4.0 and Microsoft Visual Studio 2010. He has also explained why we need functional programming and some features of F#- A new functional programming language by Microsoft. Indeed it was great i have learnt lot about that in this session.

PICT0049

Visual Studio 2010 enhancement for Developers By Prabhjot Bakshi

PICT0054

Me(First from Left) with Mahesh Dhola,Prabhjot Bakshi and other Ahmedabad Group Members

Overall it was a great event and thank you once again Microsoft for organizing such events.

Shout it
Share:
Tuesday, January 5, 2010

Creating Hello World application with Silverlight 3.0 with Visual Studio 2010

Silvelight is latest buzz in Microsoft.NET Technologies. Silverlight enable us to create rich user interface for the web based application. Let create a simple application to understand how Silverlight application works.

We will start creating application with file menu –> New Project –>Silverlight application a dialog for silverlight application will open like following.

Hello Word application by silver light 3.0

Once you create a Silverlight application a new dialog will open to create a website which will host Silvelight application like following.

SilverLight

This website are used for hosting Silvelight application. Please note that Silverlight application can also run with simple html file also. After clicking on Ok it will create a simple project like following in solution explorer.

Solution Explorer,Silver Light 3.0,ASP.NET 4.0

Now let's Create a simple button and on clicking on that button will print “Hello World” on screen.With Silvelight used Microsoft new UI Language called XAML which used to define the object in the SilverLight.

Once we create a silvelight application which will create a MainPage.xaml and MainPage.xaml.cs file for the same. It will create by default XAML like following.

<UserControl x:Class="MySilverLight.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">

<Grid x:Name="LayoutRoot" Background="White">

</Grid>
</UserControl>
Here grid will be act as container like as we are using content pane in our asp.net application. Which can host the another objects like button text and other objects. Now I am creating a simple hello world button via adding following xml between <Grid> and </Grid> tag.
<Button x:Name="HelloWorldButton" Content="Push to print Hello World on Screen " Height="25" Width="250"></Button> 

Here x:name is name of button and content is text that will display on button,width will specify width of button and height will specify height of button. It will create a simple button like following in the design layout of silverlight application as following.

SilverLight 3.0,

Now let add a text block object which will print the Hello world text on the screen after clicking button with following XAML.
<TextBlock x:Name="Mytextbox" Text="Print Text" Height="25" Margin="75,197,92,78"></TextBlock>
Which will create a text block just below the button like following. Here margin will define the margin from four side just like html. Text block will behave just like label in asp.net application

TextBlock, SilverLight Button, Silverlight 3.0

After that Let’s add a add a click event to button via modifying existing XAML like following .
<Button x:Name="HelloWorldButton" Content="Push to print Hello World on Screen " Height="25px" Width="250px" Click="HelloWorldButton_Click" ></Button> 
It will create a click handler for the button we have added after then we can add code to print Hello World!! to event handler we have just create like following.
private void HelloWorldButton_Click(object sender, RoutedEventArgs e)
{
Mytextbox.Text = "Hello World!!!";
}
Now compile and run the application it will open a browser and once you click the button it will print a hello world!! text like following.

Silverlight in Browser,SilverLigh Helloworld


Technorati Tags: ,
Shout it
kick it on DotNetKicks.com
Share:

Support this blog-Buy me a coffee

Buy me a coffeeBuy me a coffee
Search This Blog
Subscribe to my blog

  

My Mvp Profile
Follow us on facebook
Blog Archive
Total Pageviews