Ramani Sandeep's Blog

DotNetting – Fast , Easy Way of Developing Applications

Archive for the ‘ASP.NET’ Category

Common performance issues on ASP.NET web sites

Posted by Ramani Sandeep on February 2, 2011

I spend a lot of my time analysing the performance of web sites and tuning the applications to make the sites run more efficiently and scale better. Overtime I’ve pulled together a checklist of some of the more common performance issues that I see and how to resolve them, and I thought it was about time I shared them here.

Most of the issues I’ve identified are straightforward to fix (many are just configuration changes) and can give significant improvements to the scalability and the responsiveness of your web site. Some of them you may well already be aware of and I’m still amazed how many of the more obvious ones don’t get implemented as a matter of course, but then it keeps me in a job!

This post is broken down into three sections; the first is cold start improvements, or “why does my web site take so long to start up?”. This involves looking at what the IIS worker processes (w3wp.exe) are doing during initialisation, prior to completing the initial client request that caused them to launch.

The second section, which is generally more important, looks at the efficiency of processing requests once the server has “warmed up”, and is hopefully the state that the web site will spend most of its time in!

Finally the third section provides a general discussion around accessing SQL Server and web services from within web applications. These aren’t necessarily quick wins and may involve some changes to interfaces (or even the solutions architecture) to successfully implement, Finally, I’ll reveal the three golden rules for producing fast, scalable applications that I’ve derived from my investigations.

For each issue, I’ve included a brief description and references to where more information on the issue can be obtained and how to resolve it.

Read more…

Hope this will help !!!

Jay Ganesh

Posted in ASP.NET, Performance | Tagged: , , | 1 Comment »

Bind enum to ddl

Posted by Ramani Sandeep on September 8, 2010

Sometime we need to bind the value and the name of the enum to the dropdownlist. here is the code that will help us to achieve this.

here I have created a method to convert enum into hashtable :

    public Hashtable ConvertEnumToHashTable(Type myenum)
    {
        string[] names = Enum.GetNames(myenum);
        Array values = Enum.GetValues(myenum);
        Hashtable ht = new Hashtable();
        for (int i = 0; i < names.Length; i++)
        {
            ht.Add(Convert.ToInt32(values.GetValue(i)).ToString(), names[i]);
        }
        return ht;
    }

Now here is code that shows you how to use this function :

    protected void Page_Load(object sender, EventArgs e)
    {
        Hashtable ht = ConvertEnumToHashTable(typeof(myenum));
        myDDL.DataSource = ht;
        myDDL.DataTextField = "value";
        myDDL.DataValueField = "key";

        myDDL.DataBind();

    }

Hope this code will help !!!

Jay Ganesh

Posted in ASP.NET, C# 2.0 | Tagged: , , , | 1 Comment »

Securing ASP.Net Web Services with Forms Authentication

Posted by Ramani Sandeep on June 10, 2010

In this article we show how Forms Authentication can be used to secure ASP.Net Web Services, using the built-in ASP.Net Membership Provider classes which utilize SQL Server to store usernames and passwords.

Why?

Adding a Web Service, (also called an Application Programming Interface, or API for short) to an existing web site or desktop application (of the client-server variety) is a great way to enable additional and innovative uses of the data it holds, and also extend its reach to different development platforms such as native Apple and Linux applications , or to native mobile device applications such as those on Apple’s iPhone.

Read more

Hope this will helps !!!

Jay Ganesh

Posted in ASP.NET, ASP.NET 3.5, ASP.NET 4.0, Web Services | Tagged: , , , , | Leave a Comment »

Yahoo! News Rotator using jQuery, CSS, JSON, and ASP.NET

Posted by Ramani Sandeep on March 31, 2010

This Yahoo! news rotator control gives us the possibility of displaying several main news stories within the same area of a web page. News is taken apart to several pages in order to place them in a specified area. Each page also contains a couple of news items.

The control uses jQuery to:

  •     Send a jQuery AJAX request to a web server to get news in JSON format
  •     Bind data (news in the form of JSON) to HTML controls
  •     Set the control style after data binding
  •     Navigate between news
  •     Interact with user
  •     Change and set styles
  •     Do JavaScript effects

The news rotator control uses ASP.NET to gather news from a news storage (for example, database, XML file, RSS, …), to cast news into a custom type (NewsItem), then convert a collection of NewsItem objects to JSON format and send it to the client as a news rotator datasource.

Read more

Hope this helps !!!

Jay Ganesh

Posted in ASP.NET, JQuery | Tagged: , | Leave a Comment »

Integrating Twitter Into An ASP.NET Website

Posted by Ramani Sandeep on February 18, 2010

If you want to integrate Twitter into your ASP.NET website there is one API called twitterizer available (Open Source).

There are some projects developed using this API. you can view that projects from here

Here is the one of the tutorial written by Scott Mitchell to explain how to use twitterizer api in asp.net

Integrating Twitter Into An ASP.NET Website By Scott Mitchell

Twitter is a popular social networking web service for writing and sharing short messages. These tidy text messages are referred to as tweets and are limited to 140 characters. Users can leave tweets and follow other users directly from Twitter’s website or by using the Twitter API. Twitter’s API makes it possible to integrate Twitter with external applications. For example, you can use the Twitter API to display your latest tweets on your blog. A mom and pop online store could integrate Twitter such that a new tweet was added each time a customer completed an order. And ELMAH, a popular open-source error logging library, can be configured to send error notifications to Twitter.

Twitter’s API is implemented over HTTP using the design principles of Representational State Transfer (REST). In a nutshell, inter-operating with the Twitter API involves a client – your application – sending an XML-formatted message over HTTP to the server – Twitter’s website. The server responds with an XML-formatted message that contains status information and data. While you can certainly interface with this API by writing your own code to communicate with the Twitter API over HTTP along with the code that creates and parses the XML payloads exchanged between the client and server, such work is unnecessary since there are many community-created Twitter API libraries for a variety of programming frameworks.

This article shows how to integrate Twitter with an ASP.NET website using the Twitterizer library, which is a free, open-source .NET library for working with the Twitter API. Specifically, this article shows how to retrieve your latest tweets and how to post a tweet using Twitterizer.

Read more

Hope this will help

Jay Ganesh

Posted in API Integration, ASP.NET | Tagged: , | 5 Comments »

Redirect from Http to Https in ASP.NET

Posted by Ramani Sandeep on February 17, 2010

There are a few ways to redirect from http to https in asp.net, but I wanted a somewhat simple and efficient method.  After researching a bit, I could add some code to global.asax, or make my own custom configuration section in the web.config.  Well I chose to do a little variation of a "custom" section in the web.config.  I don’t end up creating a class that inherits from ConfigurationSection, but just a few other things.

To create a custom configuration section, here are a few links you may want to look at:

http://www.4guysfromrolla.com/articles/032807-1.aspx
http://msdn.microsoft.com/en-us/library/2tw134k3%28VS.80%29.aspx

John Mendez has recently posted a vert good article on

"How to Redirect from Http to Https in ASP.NET ? "

You can read full article here : http://www.xdevsoftware.com/blog/post/Redirect-from-Http-to-Https-in-ASPNET.aspx

Hope this will help

Jay Ganesh

Posted in ASP.NET | Tagged: | 1 Comment »

Base Page For Detecting Session Timeout in ASP.Net/C#

Posted by Ramani Sandeep on February 4, 2010

In this tutorial we will be going over how to create a base page class to handle your sessions. The number one question I get asked time and time again is how to manage sessions, and how to detect if a session has expired. Back in the days before .Net things were a little more complicated when it came to solving this riddle, but with the advent of the .Net Framework 2.0 a new class was introduced, the HttpSessionState Class, which is a member of the System.Web.SessionState Namespace. The new HttpSessionState Class gives us access to session state items and other lifetime management methods.

One of the items in the HttpSessionState class we will be looking at is the IsNewSession Property. This property lets us know whether the current session was created wtih the current request, or if it was an existing session. This is invaluable as we can use it to determine if the users session had expired or timed out. The IsNewSession Property is more robust and advanced then simply checking if the session is null because it takes into account a session timeout as well.

Read more

Posted in ASP.NET, C# 2.0 | Tagged: , , | Leave a Comment »

Simple task Scheduling using Global.asax

Posted by Ramani Sandeep on February 1, 2010

A frequent requirement for ASP.NET developers is to schedule tasks at regular intervals. This can include site maintenance tasks, like cleaning up old files, emailing newsletters on a schedule etc. This article examines one easy option for managing tasks like these without having to configure external tools, and discusses a couple of alternatives.

Read more

Simulate a Windows Service using ASP.NET to run scheduled jobs By Omar Al Zabir

How to run scheduled jobs from ASP.NET without requiring a Windows Service to be installed on the server? Very often we need to run some maintenance tasks or scheduled tasks like sending reminder emails to users from our websites. This can only be achieved using a Windows service. ASP.NET being stateless provides no support to run some code continuously or to run code at a scheduled time. As a result, we have to make our own Windows Services in order to run scheduled jobs or cron jobs. But in a shared hosted environment, we do not always have the luxury to deploy our own Windows service to our hosting provider�s web server. We either have to buy a dedicated server which is very costly, or sacrifice such features in our web solution. However, running a scheduled task is a very handy feature especially for sending reminder emails to users, maintenance reports to administrators, or run cleanup operations etc. So, I will show you a tricky way to run scheduled jobs using pure ASP.NET without requiring any Windows service. This solution runs on any hosting service providing just ASP.NET hosting. As a result, you can have the scheduled job feature in your ASP.NET web projects without buying dedicated servers.

Read more

Hope this helps

Jay Ganesh

Shout it

Posted in ASP.NET, ASP.NET 3.5, ASP.NET 4.0 | Tagged: , | Leave a Comment »

Best Practices for Speeding Up Your Web Site

Posted by Ramani Sandeep on January 30, 2010

The Exceptional Performance team has identified a number of best practices for making web pages fast. The list includes 34 best practices divided into 7 categories.

1) Content

  • Minimize HTTP Requests
  • Reduce DNS Lookups
  • Avoid Redirects
  • Make Ajax Cacheable
  • Post-load Components
  • Preload Components
  • Reduce the Number of DOM Elements
  • Split Components Across Domains
  • Minimize the Number of iframes

2) Server

  • Use a Content Delivery Network
  • Add an Expires or a Cache-Control Header
  • Gzip Components
  • Configure ETags
  • Flush the Buffer Early
  • Use GET for AJAX Requests

3) CSS

  • Put Stylesheets at the Top
  • Avoid CSS Expressions
  • Choose <link> over @import
  • Avoid Filters

4) Javascript

  • Put Scripts at the Bottom
  • Make JavaScript and CSS External
  • Minify JavaScript and CSS
  • Remove Duplicate Scripts
  • Minimize DOM Access
  • Develop Smart Event Handlers

5) Cookie

  • Reduce Cookie Size
  • Use Cookie-free Domains for Components

6) Images

  • Optimize Images
  • Optimize CSS Sprites
  • Don’t Scale Images in HTML
  • Make favicon.ico Small and Cacheable

7) Mobile

  • Keep Components under 25K
  • Pack Components into a Multipart Document

           Read more

Posted in ASP.NET, ASP.NET 3.5, ASP.NET 4.0, ASP.NET Ajax, Css, JavaScript, Performance | Tagged: , | Leave a Comment »

MultiSelect Dropdown in ASP.NET

Posted by Ramani Sandeep on January 29, 2010

In this article, I will show you a different way of doing a multi-select in an ASP.NET page. I will keep this article short and sweet so you can just use the code in your applications.

We are going to put our CheckBoxList ASP.NET control inside an HTML div object. I have also added code to support changing the background color of the selected row.

Read more

Shout it

Posted in ASP.NET, JavaScript | Tagged: , , | Leave a Comment »

 
Follow

Get every new post delivered to your Inbox.

Join 37 other followers