Jack @ ASP.NET

As a software engineer, I focus on .NET, especially asp.net, C#, WCF and so on, and I am also very interested in Search Engine Optimization.

Entries Tagged ‘browser’

How much does your browsers support HTML5?

More and more browsers begin to support HTML5, here is an online tool(website) to check the scores of your browser in supporting HTML5: http://html5test.com/

And from the statics, Chrome 13.0.782 get a scores of 341.

Performance tuning tips for ASP.NET and IIS 7

1. Browser caching

In part 1, we looked at how it was possible to set an expiration header to any static file such as JavaScript and CSS files, so the browser would cache them for a long time and thereby optimize both for bandwidth and the number of requested files going from server to browser.

The problem with setting a browser cache expiration date of i.e. a JavaScript file to a year in the future becomes clear when you change the file before it expires in your visitor’s browsers. They simply won’t see the changes until they either clear their cache or hits F5 manually.

2. Bundle multiple files

Another common website performance issue is that there are many JavaScript and CSS files included on a page. This scenario results in the browser have to download a lot of extra files and that all slows down the performance of a website. The solution to this is also very simple when you’ve first completed the above steps to register the HTTP handler in web.config and called the BundleHelper.InsertFile method when inserting JavaScript and CSS files.

3. HTTP compression

You’ve always been able to perform HTTP compression in ASP.NET by using third-party libraries or own custom built ones. With IIS 7 you can now throw that away and utilize the build-in compression available from the web.config. Add the following line to enable HTTP compression:

<urlCompression doDynamicCompression=”true” doStaticCompression=”true” dynamicCompressionBeforeCache=”true”/>

By default, only text based content types are compressed.

4. Cache static files

To speed up the load time for the visitors, it is crucial that everything that can be cached by the browser IS cached by the browser. That includes static files such as images, stylesheets and script files. By letting the browser cache all these files means it doesn’t need to request them again for the duration of the cache period. That saves you and your visitors a lot of bandwidth and makes the page load faster. A well primed browser cache also triggers the load and DOMContentLoaded event sooner.

It’s worth noticing that the output caching respects file changes and therefore refreshes ever time changes are made to the JavaScript and CSS files tunnelled through this code.

ASP.NET Interview Questions and Answers

1. Explain the differences between Server-side and Client-side code?
Server-side code executes on the server. Client-side code executes in the client’s browser.aspnet

2. What type of code (server or client) is found in a Code-Behind class?
Server-side code. Since code-behind is executed on the server. However, during the code-behind’s execution on the server, it can render client-side code such as JavaScript to be processed in the clients browser. But just to be clear, code-behind executes on the server, thus making it server-side code.

3. Should user input data validation occur server-side or client-side?
All user input data validation should occur on the server at a minimum. Additionally, client-side validation can be performed where deemed appropriate and feasable to provide a richer, more responsive experience for the user.

4. What is the difference between Server.Transfer and Response.Redirect?
Why would I choose one over the other? Server.Transfer transfers page processing from one page directly to the next page without making a round-trip back to the client’s browser. This provides a faster response with a little less overhead on the server. Server.Transfer does not update the clients url history list or current url. Response.Redirect is used to redirect the user’s browser to another page or site. This performas a trip back to the client where the client’s browser is redirected to the new page. The user’s browser history list is updated to reflect the new address.

5. What is the Global.asax used for?
The Global.asax (including the Global.asax.cs file) is used to implement application and session level events.

6. What are the Application_Start and Session_Start subroutines used for?
This is where you can set the specific variables for the Application and Session objects.

7. Whats an assembly?
Assemblies are the building blocks of the .NET framework.

8. Can you explain what inheritance is and an example of when you might use it?
When you want to inherit (use the functionality of) another class. Example: With a base class named Employee, a Manager class could be derived from the Employee base class.

9. Describe the difference between inline and code behind.
Inline code written along side the html in a page. Code-behind is code written in a separate file and referenced by the .aspx page.

10. Explain what a diffgram is, and a good use for one?
The DiffGram is one of the two XML formats that you can use to render DataSet object contents to XML. A good use is reading database data to an XML file to be sent to a Web Service.

Silverlight 4 demos available now!

Demos are available now, You can download the keynote demos at http://www.silverlight.net/community/samples/silverlight-4-beta/ (source code + VS project file included with each sample).

Keynote Demos

PhotoBooth Application

The PhotoBooth application demonstrates some of the fun things you can do with the new WebCam and Microphone support in Silverlight 4.  It allows you to record videos and take photos within the browser – and then optionally apply effects to them (for example: the bulge effect below).  For kicks you can publish a photo of any of the pictures to Twitter :-)

image

BarCode Scanner

The BarCode Scanner application also uses the new WebCam support in Silverlight 4. It allows you to scan an ISBN barcode from the back of a book, and will then use Amazon web-services to look up details about the book online:

image

Rich Notepad

The rich notepad application shows off some of the new text editing features in Silverlight 4.  It allows you to edit rich text within the browser, supports Bidi text (including Arabic and Hebrew), supports both left-to-right and right-to-left control layout (RTL is show below – notice how the scroll-bar is on the left hand side of the screen), supports programmatic copy/paste to the system clipboard, custom right-click context menus, printing, and drag/drop of files from the desktop into the browser to edit:

image

HTML Hosting

The HTML Hosting application shows off using the new Silverlight 4 webbrowser control in an out of browser application (note: you must run the application out of the browser for it to work).  It allows you to use the control both interactively (meaning you can click the HTML within it and run it like an application).  It also allows you to use the hosted HTML as a brush that you can apply to other Silverlight controls. For fun you can click the MSDN.com tab below and you’ll get rick-rolled to YouTube.  You can still use the HTML as a brush and carve it up into a jigsaw – even though the video is still playing (using Flash hosted within the HTML):

image