Life of Sotware Developer...

Wednesday, May 19, 2010 6:25 AM Posted by Hrishi
Labels:

0

As usual i was, browsing the internet at my leisure time and found something interesting...

Following picture depicts life of a Software Developer, its real tough  ;)



Special thanks to my friend Indrajeet for helping me find this pic...

VS2010 Community Wallpapers

Thursday, May 13, 2010 3:35 AM Posted by Hrishi

0

     Here are some awesome VS2010 Community Wallpapers !!! 












For more wallpapers please visit VS2010Wallpapers

Reference : ScottGu's Blog

Session Overview

Tuesday, April 27, 2010 2:31 AM Posted by Hrishi
Labels:

0

ASP.NET Session state provides a place to store values that will persist across page requests.  Values stored in Session are stored on the server and will remain in memory until they are explicitly removed or until the Session expires.

Storing and retrieving a value in the Session is as simple as:

C#

    Session["Name"] = "Hrishi"; // or Session.Add ("Name","Hrishi"); // retrievingstring

    Name = (string)Session["Name"];

By default the Session will be created within the same process that your web site runs in (InProc).  This is controlled by a setting in the web.config file:

    <sessionState mode="InProc" />

Although running the Session In Process is very convenient,  it does mean that all Session values will be lost whenever the application recycles (such as when deploying updates) .  There are alternate modes you can use that will allow the Session state to survive even when the application recycles.

The available options are:

    * Off - No session state will be stored
    * InProc - (The Default) Session state exists within the process the web is using
    * StateServer - Session data is sent to the configured stateserver service
    * SQLServer - Session data is store in the configured sql server database

Both the StateServer mode and the SQLServer mode allow Session state to survive an application recycle.  But, when storing reference type objects (such as class instances), they can only be stored to StateServer or SQLServer if they have been marked with the Serializable attribute.

An important consideration for using Session state is that the Session does expire.  By default, if a user does not access their Session data within 20 minutes (by default), the Session will expire and all items that had been stored in the Session will be discarded. Because of this, it is important to check the object that is returned from the Session to see if it exists or if it is null before you try to work with it. For example

object sessionObject = Session["someObject"];
if (sessionObject != null) {
 myLabel.Text = sessionObject.ToString();
}

The Session Timeout is adjustable through a web.config setting but increasing the timeout value can put memory pressure on your server that may be undesirable

     <sessionState timeout="number of minutes" />
Other commonly used Session methods are:
  1. Session.Abandon() - removes the Session and all items that it contains
  2. Session.Clear() - removes all items from the Session
  3. Session.RemoveAll() - removes all items from the Session
  4. Session.Remove("itemName") - removes the item that was stored under the name "itemName"
    Reference : MSDN

    VS 2010 Tip

    Wednesday, April 21, 2010 5:45 AM Posted by Hrishi
    Labels: ,

    0

    In the new VS2010 UI, the start page has been completely re-written.  Part of the changes made were to hide the New Website and Open Website buttons.  Basically it went from the old look in VS2008:


    To the new look in VS2010:


    Of course, ASP.NET website projects are still around and not going away soon.  Here’s a very quick way to make them show up on the Start Page again.

       1. Download the StartPageWeb.zip file linked here
       2. Extract StartPageWeb.xaml and copy it into your Documents\Visual Studio 10.0\StartPages folder
       3. Open Visual Studio 2010 and open Tools –> Options.  Find the option under Environment –> Startup, and set the Customize Start Page dropdown to point at the new XAML file.

    That’s it!  Now your start page will look like this:





    Note: you may get a security warning that the file is not trusted.  This is due to downloading it from the scary Internet.  From Windows Explorer, you can right-click the file, select Properties, and then select the Unblock button by the bottom:

    Web Crawlers Detection in ASP.Net

    Tuesday, April 20, 2010 2:18 AM Posted by Hrishi
    Labels: ,

    0


    Here is a way of detecting search engine (Google, live…) crawlers,spiders etc..


     System.Web.HttpBrowserCapabilities clientBrowserCaps = Request.Browser;
                if (((System.Web.Configuration.HttpCapabilitiesBase)clientBrowserCaps).Crawler)
                {
                    Response.Write ( "Browser is a search engine.");
                }
                else
                {
                   Response.Write ("Browser is not a search engine.");
                }

                //Here is another approach..

                if (Request.ServerVariables["HTTP_USER_AGENT"].Contains("Googlebot"))
                {
                    //log Google bot visit
                }
                else if (Request.ServerVariables["HTTP_USER_AGENT"].Contains("msnbot"))
                {
                    //log MSN bot visit
                }
                else if (Request.ServerVariables["HTTP_USER_AGENT"].Contains("Yahoo"))
                {
                    //log yahoo bot visit
                }
                else
                {
                    //similarly you can check for other search engines
                }

    Three - tier web applications

    1:58 AM Posted by Hrishi
    Labels:

    0


    People always think that they need to structure their web applications into multiple tiers to separate the concerns. The advice is to move the business and data logic out of the web project into two different projects so you end up with the classic 3 tier model – presentation, business and data. This advice is good.

    The strange thing is that this advice is given to web developers as a way of structuring web applications. I’ve always found that very odd. Not that web developers don’t write business and data logic, but I don’t see the connection between web development and business/data logic development.
    Let me explain

    The premise for the advice is that business/data logic is part of building a website. This is wrong. A website is a visual representation that interacts with the business logic, but the business logic doesn’t and shouldn’t care about the website. The business logic is an API consumed by the website and nothing more. The business logic still doesn’t care if its public methods (API) are used on a website, in a Windows Forms application or in a web service. Ergo, business logic is not part of building a website. The premise is wrong.

    In a typical 3 tier web solution you have three projects – the website, business- and data logic projects. That makes it a little confusing to believe that the business and data logic has nothing to do with building a website. But if you think of the three projects as the building blocks in creating a solution then it’s easier to understand. In other words; you don’t separate a website into three tiers by separating the business and data logic into their own projects, you separate the solution into three tiers. Since the website is just the UI in such a solution, it is wrong statement that your website is 3-tiered and the premise is then wrong.
    The three tiers

    The reason why I’ve always found this advice odd is that I always build my websites in three tiers, but it has nothing to do with the business and data logic. The three tiers I use in web development are specific for the website only. The tiers are:

    1. User interface
    2. User interface logic
    3. Presentation logic
    The names are just some that I use and may be different elsewhere.
    User interface (UI)

    The UI is the HTML, JavaScript and CSS that makes up the visual look and feel and the browser behavior. It lives in pages (.aspx), user controls (.ascx), .js and .css files. In some cases also in HTTP handlers (.ashx), but mainly for custom AJAX mechanisms.
    User interface logic

    This tier is what controls the server side behaviour of the UI. It lives in code-behind files and in the App_Code folder. This logic is responsible for handling button events and differentiates the response based on the user etc. It’s also custom web control collections that could live in its own project and often do.
    Presentation logic

    This is the where all the stuff goes that isn’t directly is used in the UI. It could be RSS feeds or classes used by the code-behind. Most often it’s where I put the HttpHandlers and HttpModules and the logic that controls them. It could be located in its own project or it could just be in its own folder in the App_Code or wherever it feels right to put it depending on the size of the project.

    It doesn’t really matter where the tiers are physically placed as long as they are logically separated. That’s why it often makes sense to move the tiers into their own projects to make the separation clear and the code easier to maintain and reuse.

    So a three tier web application has nothing to do with business and data logic. Remember that the business logic is just an API consumed by a website even if they both live in the same Visual Studio solution.











    ASP.Net Interview Questions

    12:44 AM Posted by Hrishi

    0

    These are some interesting ASP.Net Interview questions which i came across

       1. From constructor to destructor (taking into consideration Dispose() and    the concept of non-deterministic finalization), what the are events fired as part of the ASP.NET System.Web.UI.Page lifecycle. Why are they important? What interesting things can you do at each?
       2. What are ASHX files?  What are HttpHandlers?  Where can they be configured?
       3. What is needed to configure a new extension for use in ASP.NET? For example, what if I
       4. wanted my system to serve ASPX files with a *.jsp extension?
       5. What events fire when binding data to a data grid? What are they good for?
       6. Explain how PostBacks work, on both the client-side and server-side. How do I chain my own
       7. JavaScript into the client side without losing PostBack functionality?
       8. How does ViewState work and why is it either useful or evil?
       9. What is the OO relationship between an ASPX page and its CS/VB code behind file in ASP.NET ?
      10. What happens from the point an HTTP request is received on a TCP/IP port up until the Page fires the On_Load event?
      11. How does IIS communicate at runtime with ASP.NET?  Where is ASP.NET at runtime in IIS5? IIS6?
      12. What is an assembly binding redirect? Where are the places an administrator or developer can affect how assembly binding policy is applied?
      13. Compare and contrast LoadLibrary(), CoCreateInstance(), CreateObject() and Assembly.Load().

    ASP.NET Application Life Cycle Overview for IIS 7.0

    Monday, April 19, 2010 4:36 AM Posted by Hrishi
    Labels:

    0

    A request in IIS 7.0 Integrated mode passes through stages that are like the stages of requests for ASP.NET resources in IIS 6.0. However, in IIS 7.0, these stages include several additional application events, such as the MapRequestHandler, LogRequest, and PostLogRequest events.

    The main difference in processing stages between IIS 7.0 and IIS 6.0 is in how ASP.NET is integrated with the IIS server. In IIS 6.0, there are two request processing pipelines. One pipeline is for native-code ISAPI filters and extension components. The other pipeline is for managed-code application components such as ASP.NET. In IIS 7.0, the ASP.NET runtime is integrated with the Web server so that there is one unified request processing pipeline for all requests. For ASP.NET developers, the benefits of the integrated pipeline are as follows:

    • The integrated pipeline raises all the events that are exposed by the HttpApplication object, which enables existing ASP.NET HTTP modules to work in IIS 7.0 Integrated mode.

    • Both native-code and managed-code modules can be configured at the Web server, Web site, or Web application level. This includes the built-in ASP.NET managed-code modules for session state, forms authentication, profiles, and role management. Furthermore, managed-code modules can be enabled or disabled for all requests, regardless of whether the request is for an ASP.NET resource like an .aspx file.

    • Managed-code modules can be invoked at any stage in the pipeline. This includes before any server processing occurs for the request, after all server processing has occurred, or anywhere in between.

    • You can register and enable or disable modules through an application’s Web.config file.
    The following illustration shows the configuration of an application's request pipeline. The example includes the following:

    • The Anonymous native-code module and the Forms managed-code module (which corresponds to FormsAuthenticationModule). These modules are configured, and they are invoked during the Authentication stage of the request.

    • The Basic native-code module and the Windows managed-code module (which corresponds to WindowsAuthenticationModule). They are shown, but they are not configured for the application.

    • The Execute handler stage, where the handler (a module scoped to a URL) is invoked to construct the response. For .aspx files, the PageHandlerFactory handler is used to respond to the request. For static files, the native-code StaticFileModule module responds to the request. 

    • The Trace native-code module. This is shown, but it is not configured for the application.

    • The Custom module managed-code class. It is invoked during the Log request stage. 


    New features in C# 4.0

    Wednesday, April 14, 2010 4:32 AM Posted by Hrishi
    Labels:

    0

    Introduction


    The major theme for C# 4.0 is dynamic programming. Increasingly, objects are “dynamic” in the sense that their structure and behavior is not captured by a static type, or at least not one that the compiler knows about when compiling your program. Some examples include

    ·         objects from dynamic programming languages, such as Python or by Ruby

    ·         COM objects accessed through IDispatch

    ·         ordinary .NET types accessed through reflection

    ·         objects with changing structure, such as HTML DOM script objects

    ·         data readers and other user defined dynamic objects

    While C# remains a statically typed language, we aim to vastly improve the interaction with such objects.

    A secondary theme is co-evolution with Visual Basic. Going forward we will aim to maintain the individual character of each language, but at the same time important new features should be introduced in both languages at the same time. They should be differentiated more by style and feel than by feature set.

    The new features in C# 4.0 fall into four groups:

    Dynamic binding

    Dynamic binding allows you to write method, operator and indexer calls, property and field accesses, and even object invocations which bypass the C# static type checking and instead gets resolved at runtime.
    Named and optional arguments

    Parameters in C# can now be specified as optional by providing a default value for them in a member declaration. When the member is invoked, optional arguments can be omitted. Furthermore, any argument can be passed by parameter name instead of position.
    COM specific interop features

    Dynamic binding as well as named and optional arguments help making programming against COM less painful than today. On top of that, however, we are adding a number of other features that further improve the interop experience specifically with COM.

    Variance

    It used to be that an IEnumerable wasn’t an IEnumerable. Now it is – C# embraces type safe “co-and contravariance,” and common BCL types are updated to take advantage of that.

    Typical State Management Interview Questions

    Tuesday, April 13, 2010 4:25 AM Posted by Hrishi
    Labels:

    1

    ASP.NET offers a number of places to store state, both on the client and server. However, sometimes it's difficult to decide where you should put things and how to make that decision.

    You choices for state management include:

    Application - Stored on the server and shared for all users. Does not expire.  Deprecated by Cache (below).

    Cache - Stored on the server and shared for all users. Can expire.

    Session - Stored on the server.  Unique for each user.  Can expire.

    ViewState - Stored in a hidden page input (by default).  Does not expire.

    Cookies - Stored at the client. Can expire.

    QueryString - Passed in the URL.  Must be maintained with each request.

    Context.Items - Only lasts for one request's lifetime.  More.

    Profile - Stores the data in the database. Can be used to retain user data over multiple request and session.

    State and Life Cycle

    Saturday, April 10, 2010 11:51 PM Posted by Hrishi
    Labels:

    0



    ASP.NET manages four types of state:


    Control state
    Used to provide features such as paging and sorting of GridView controls. Control
    state cannot be modified, accessed directly, or disabled.


    View state
    The state of all the controls on the page. View state only lasts for that one page
    display, and is updated every time the page is redrawn. It can be disabled for
    specific controls, the page, or the entire web site.


    Session state
    Data specifically saved across page posts, for use by all the pages in a web
    application.


    Application state
    Data available to all the users of a web application, even across multiple
    sessions.

    ASP.Net Application Restarts

    8:46 AM Posted by Hrishi
    Labels:

    0




    What Causes Application Restarts?

    There are a few reasons why an ASP.NET application can be restarted. For the most part, an application is restarted to ensure that latent bugs or memory leaks don’t affect in the long run the overall behavior of the application. Another reason is that too many dynamic changes to ASPX pages may have caused too large a number of assemblies (typically, one per page) to be loaded in memory. Any application that consumes more than a certain share of virtual memory is killed and restarted. The ASP.NET runtime environment implements a good deal of checks and automatically restarts an application

    if any the following scenarios occur:

    The maximum limit of dynamic page compilations is reached. This limit is
    configurable through the
    web.config file.

    The physical path of the Web application has changed, or any directory under
    the Web application folder is renamed.
    Changes occurred in global.asax,machine.config, or web.config in the application root, or in the Bin directory or any of its subdirectories.

    Changes occurred in the code-access security policy file, if one exists.
    Too many files are changed in one of the content directories. ( Typically, this
    happens if files are generated on the  y when requested.)
    Changes occurred to settings that control the restart/shutdown of the ASP.
    NET worker process. These settings are read from machine.config if you don’t
    use Windows 2003 Server with the IIS 6.0 process model. If you’re taking full
    advantage of IIS 6.0, an application is restarted if you modify properties in the
    Application Pools node of the IIS manager.

    In addition to all this, in ASP.NET an application can be restarted programmatically by calling HttpRuntime.UnloadAppDomain.