Posts

Showing posts from May, 2014

Session Id changes in ASP.NET MVC on every new page request

I faced and issue in ASP.NET MVC application where the value of SessionID variable changes on consecutive page requests.

The reason is either you don't have a Global.asax file in your solution, or you have a global.asax in your solution without the definition of session end and session start. So the web server actually doesn't take care of session start and end event per application basis, and it generates a new key on every page request.
You should have a Global.asax in your project and it shall have following two functions added:

 protected void Session_Start()
        { }

        protected void Session_End()
        { }


This should work perfectly.......
Enjoy coding!

Generate a Pie Chart at runtime, C#, .NET

We can quickly write a function which returns a Pie Chart at runtime. Assuming that we are making a pie chart for the number of visitors/users from different countries, we will pass System.Data.DataTable as parameter to the function and it shall return a Chart object.

Please add following namespaces to the page/class.

using System.Windows.Forms.DataVisualization.Charting;
using System.Drawing;
using System.Data;

Write the following function to get a Chart as return Parameter. You can pass a Datatable to the funtion with following schema,
Datatable dt (Country Text, Users Int)

Following is the function :

protected internal Chart GetPieChart(DataTable dtChartData)
        {
            Chart pieChart = new Chart()
            {
                Width = 800,
                Height = 800
            };

            ChartArea chartArea1 = new ChartArea();
            Legend legend1 = new Legend() { BackColor = Color.BurlyWood, ForeColor = Color.White, Title = "Countries" };
            chartArea1.N…

Managing Crawl Rules in SharePoint 2013

Image
It's very simple to configure crawling rules in SP 2013 as it was in 2010.
Lets have a quick walk through of it. Crawl rules are used to specfiy detailed logic to the crawler while content crawling. There are situations where we don't want to crawl a particular content or we want exceptional content to be crawled inside that. There are many option available.
Prevent content on a site from being crawled. For example, if you created a content source to crawl http://www.ks.com, but you do not want the search system to crawl content from the subdirectory http://www.ks.com/downloads, create a crawl rule to exclude content from that subdirectory. Crawl content on a site that would be excluded otherwise. For example, if you excluded content from http://www.ks.com/downloads from being crawled, but you want content in the subdirectory http://www.ks.com/downloads/content to be crawled, create a crawl rule to include content from that subdirectory. Specify authentication credentials. If a si…