Migration to Net 4.0, ASP.Net 4.0 hosting server

Today, I have migrated my blog to a new server running on .Net 4.0/ASP.Net 4.0 platforms. Now my blog supports Silverlight 4/RIA, MVC2, WCF, WPF, Microsoft Chart controls, Entity framework, Linq technologies. In the coming few days, I’ll try to post and host some examples in these technologies.

The first thing I have noticed is the response time. My blog is running under IIS 7.0 and the response time is far better than my old server. The good thing here is I can access IIS 7 through IIS manager remotely and a nice web control panel to manage .net applications including recycling pools.

Also, I have moved my DB from SQLServer 2005 to SQLite 3. SQLite(VistaDB, Compact SQL Server) is the best option for blogs and other small sites because nothing much can be stored only blog related posts and settings and is easier to maintain.

ADO.Net Data Services

ASP.Net 3.5 SP1 includes a new concept ADO.Net Data service. Commonly you can ask why we need one more service concept if we have WCF, ASMX services already?. Simply I could write a ASMX or WCF service to  provide API interface for my data. Yes its possible, the problem here is we have to write the code for everything(sorting, filtering, joins, CRUD operations etc) from scratch. Also for supporting different formats(JSON, ATOM, XML etc). Additional code required if we wish to expose it as a RESTful service. ADO.Net data services designed specially for these purpose. In a one go, we can a have service that performs CRUD operations, sorting, filtering etc and provides a RESTful interface supporting ATOM feeds and JSON formats without writing too much code and which well works with Entity Framework. Read more

Ajax File Download

How to download a file with events as like that of Ajax Upload. Its impossible to attach an event before and after a download through javascript. Browser doesn’t allow this type of events for security reasons. Usually a file can be downloaded simply clicking on <A> link pointing to the URL and browser prompts a save dialog to the user.

A file download sometimes may take several minutes, there is no way to display a progress message (ex: downloading.. please wait) to the user like that of Ajax loading (once save dialog displayed , it should be hidden). Read more

Importing data into SqlServer from Excel

Excel spreadsheets can be imported into SQL server in various ways. The simple and quickest methods are with using Linked Servers and Distributed queries. The difference is how the connection is used. Linked servers uses a persistent configured connection where as Distributed queries uses a dynamic connection. Linked servers are not suitable when we want to import more than one document. For every document there a linked connection should be configured(painful).

You can configure Linked connection through Server Objects->Linked Servers-> New Linked Connection (See below image) from the Management studio object explorer. Use select statement with OPENQUERY to read excel data. Read more

LinQ to SQL or Entity Framework ?

A common question arises when working with .Net 3.5 data models.

A nice article explaining differences between LinQ to SQL and Entity Framework is at party libraries are available for supporting other databases(like LinQtoOracle etc..).

b) Entity Framework is an ORM DB and is based on application-oriented data model. Its a loosely coupled and may differs from existing DB schema. It represents many:many relations(flexible mapping) and provides different layers to your DB.  Entity Framework works with both SQL Server and 3rd party Databases(.edmx files). If your thinking for a common layer for all the databases, loosely coupled(independent of DB Schema), Entity Framework is the best option.

Visual Studio 2010

Yesterday I have installed Visual Studio 2010 on my Windows 7. Wow. I am surprised with its new look & feel, performance, cool features. No doubt, I can tell now it will be my favorite.  Its still in Beta version and will be releasing in March 2010. So many improvements around AJAX, Core services, WebForms, MVC, Designer, Deployment when compared to VS2008.

Windows 7

Last week, I received a complimentary signature copy of Windows 7 Ultimate from Microsoft. I think right now in Australia, it costs around AU $400-$470. I installed with x64 bit version replacing my erroneous Vista version. It has cool features, performance wise better than vista. The beauty is it will recommend with possible drivers and updates on install where as vista doesn’t(manual install). I haven’t encountered any errors and compatibility issues, loving it.

Loading ASP.Net web page(s) faster

The following will help in loading a web page faster.

  • Always add javascript code at the end of a web page.

Add javascript code between end tags of the body and html tags. Browser loads DOM objects first and javascript code later. This will avoid blank browser loading page and user can see HTML objects in the browser very quickly.

  • Always set cache-expire in the response header.
  • Avoid viewstate for simple pages(by default view state enabled) or in pages where viewstate not needed.
  • Use gzip(or deflate) compression.

Read more