ASP.NET MVC Framework

MVC is a framework methodology that divides an application's implementation into three component roles: models, views, and controllers
  1. Models in a MVC based application are the components of the application that are responsible for maintaining state.
  2. Views in a MVC based application are the components responsible for displaying the application's user interface. Typically this UI is created off of the model data
  3. Controllers in a MVC based application are the components responsible for handling end user interaction, manipulating the model, and ultimately choosing a view to render to display UI. In a MVC application the view is only about displaying information - it is the controller that handles and responds to user input and interaction
MVC view engine: MVC having 8 alternate view engines,Brail, NDjango, NHaml, NVelocity, SharpTiles, Spark, StringTemplate and XSLT.

Razor is a view-engine developed by Microsoft and released with MVC 3 that is optimized around HTML generation using a code-focused templating approach.

Release history
Date Version
10 December 2007 ASP.NET MVC CTP
13 March 2009 ASP.NET MVC 1.0
10 March 2010 ASP.NET MVC 2.0
13 January 2011 ASP.NET MVC 3.0

How to access unmanaged code using Interop

  1. Use System.Runtime.InteropServices
  2. Use DllImport to declare the unmanaged procedure
  3. Map the data types of the procedures parameters to equivalent .NET types
  4. Call the unmanaged procedure
  5. Test it

What is Code-Access security

Code access security is a mechanism that helps limit the access to the code by protecting the resources. It defines permissions which tell about the rights to access various. It also imposes restrictions on code at run time.

Passport authentication in .NET

ASP.NET directs the user to a Passport sign-on page. The Passport service authenticates the user, stores an authentication cookie on the user’s computer and direct the user to the requested page. Next time it'll checks the user’s machine for a passport authentication cookie. If it is not available, redirect to Passport sign-on page.
  • Install the Passport SDK.
  • Set the application’s authentication mode to Passport in Web.config.
  • Set authorization to deny unauthenticated users.
  • Use the PassportAuthentication_OnAuthenticate event to access the user’s Passport profile to identify and authorize the user.
  • Implement a sign-out procedure to remove Passport cookies from the user’s machine

ACID properties of the database

All Database systems which include transaction support implement ACID properties to ensure the integrity of the database. ACID stands for Atomicity, Consistency, Isolation and Durability
  1. Atomicity: Each transaction is said to be “atomic.” If one part of the transaction fails, the entire transaction fails. Modifications on the data in the database either fail or succeed.
  2. Consistency: This property ensures that only valid data will be written to the database. If, for some reason, a transaction is executed that violates the database’s consistency rules, the entire transaction will be rolled back and the database will be restored to a state consistent with those rules.
  3. Isolation: It requires that multiple transactions occurring at the same time not impact each other’s execution.
  4. Durability: It ensures that any transaction committed to the database will not be lost.

Difference between classes and structs

Class Struct
Reference Type Value Type
Memory will be allocated in heap In Stack
Support Inheritance Not supported
Assign null values to class variable Not possible
Can have destructor Not possible

Specifying a Rendering Format in a URL

http://servername/server?/Sales/Summary&rs:Format=HTML4.0&rs:Command=Render
http://servername/server?/Sales/Summary&rs:Command=Render&rs:Format=HTML4.0&rc:Parameters=false&Year=2002

PrefixAction
rcSupplies a rendering extension with specific device information settings. 
rsTargets the report server with specific parameters.
rvPasses report parameters in a URL to a report that is stored in a SharePoint document library, for the Report Viewer Web Part. 
dspSpecifies a password with which to access a data source. 

Format types:
HTML3.2, HTML4.0, MHTML, IMAGE, EXCEL, WORD, CSV, PDF, XML, and NULL

More Info

Different types of data sources in SSRS?

SSRS use different data source. Some of them are listed below.
  1. Microsoft SQL Server
  2. Microsoft SQL Azure
  3. Microsoft SharePoint List
  4. SQL Server Analysis Service
  5. Microsoft SQL Server Parallel Data Warehouse
  6. OLEDB
  7. Oracle
  8. ODBC
  9. Report Server Model
  10. SAP Netweaver BI
  11. Hyperion Essbase
  12. Teradata
  13. XML

For More info http://msdn.microsoft.com/en-us/library/ms156450.aspx

Web service used for reporting services

Reporting Service Web Service used in SSRS. By accessing this web service you can access all report server component and also get the report deployed on report server

Different part of RDL file

RDL files are written in XML.
  1. Data (Dataset/query) 
  2. Design 
  3. Preview

What is the name of reporting services config file and what’s it’s used for?

Reporting service config file is used for report configuration details. It contains the report format and also the report import types. Report service config reside at ISS

How to deploy the Report?

Report can be deployed in three ways.
  1. Visual studio IDE
  2. report server
  3. Creating the utility : Rs.exe utility is used for deploying the report on report server.

What is report subscription?

Report subscription is to schedule the resource on particular time and to send a mailer to particular users.

Why can’t we use page total in the report body?

These built in field can be added in footer or header for better representation of the report. It can not be used in the body.

What is ADHOC Report/Report model project in SSRS?

Adhoc Reports are the reports which end user can create using report model project(Report builder). These reports have a predefined layout which is a standard layout from Microsoft. User can select columns from different table or views and can generates the request as per his or her requirement.

What are the different types of report?

Reporting Services, you can create the following types of reports.
  • Parameterized reports
    Parameter/Input values are used to generate the report. Parameterized reports are frequently used for drillthrough reports, linked reports, and subreports, connecting and filtering reports with related data. Reporting Services supports two kinds of parameters:
    1. Query parameters : Query parameters are used during data processing to select or filter data.
    2. Report parameters : Report parameters are used during report processing to show a different aspect of the data.
  • Linked reports
    A linked report is a report server item that provides an access point to an existing report. Conceptually, it is similar to a program shortcut that you use to run a program or open a file.
    A linked report is derived from an existing report and retains the original's report definition. A linked report always inherits report layout and data source properties of the original report. All other properties and settings can be different from those of the original report, including security, parameters, location, subscriptions, and schedules
  • Snapshot reports When you select a report snapshot for viewing, the report server retrieves the stored report from the report server database and shows the data and layout that were current for the report at the time the snapshot was created.
  • Cached reports
    A cached report is a saved copy of a processed report.
  • Ad hoc reports
  • Clickthrough reports
    A clickthrough report is a report that provides detailed information about the data contained within the main report.
    Clickthrough reports are available only when running SQL Server Enterprise.
    By default, the report server generates two clickthrough template types for each entity: a single instance template and a multiple instance template. The item that you click on determines which template is used. If the person reading the report clicks a scalar attribute, the single instance template is used. If the person reading the report clicks an aggregate attribute, the multiple instance template is used.
  • Drilldown reports
    Drill down reports are the reports which can collapse or expand as per requirement i.e. information can be drilled down in to minor level information if required.
  • Drillthrough reports
  • Subreports
    Sub reports are the reports which can be called in main report and can be generate through main report. Parameters can be passed from main report to sub report and basis of that report can be generated.
Verify
  • TSQL Reports:
    TSQL Reports are made up of plain SQL Query. Data source in this case is SQL server database engine.
  • MDX Reports:
    MDX reports are created through cubes. For this data source is analysis services cubes.

How to access SSRS report from program

objRPT.ShowParameterPrompts = false;
objRPT.ShowCredentialPrompts = false;

objRPT.ProcessingMode = ProcessingMode.Remote;
objRPT.ServerReport.ReportServerUrl = new Uri("http://xxxx/ReportServer");
IReportServerCredentials iRPTcre = new CustomReportCredentials("username","password","domain");
objRPT.ServerReport.ReportServerCredentials = iRPTcre;

objRPT.ServerReport.ReportPath = "/folder/reportname";

ReportParameter[] rptParams = new ReportParameter[1];
rptParams[0] = new ReportParameter("SalesOrderNumber", "SO50750");

What is the formatting code (format property) for a number with 2 decimal places?

N2

AJAX Post & Get Syntax

  • GET method
    xmlhttp.open("GET","demo_get2.asp?fname=Henry&lname=Ford",true);
    xmlhttp.send();
    
  • POST method
    xmlhttp.open("POST","ajax_test.asp",true);
    xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xmlhttp.send("fname=Henry&lname=Ford");
    
  • Status
    Property Description
    onreadystatechange Stores a function (or the name of a function) to be called automatically each time the readyState property changes
    readyState Holds the status of the XMLHttpRequest. Changes from 0 to 4:
    0: request not initialized
    1: server connection established
    2: request received
    3: processing request
    4: request finished and response is ready
    status 200: "OK"
    404: Page not found

  • Example
    <script type="text/javascript">
    function loadXMLDoc()
    {
     var xmlhttp;
     if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
       xmlhttp=new XMLHttpRequest();
        }
     else
      {// code for IE6, IE5
       xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
     xmlhttp.onreadystatechange=function()
      {
       if (xmlhttp.readyState==4 && xmlhttp.status==200) {
        document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
       }
      }
     xmlhttp.open("GET","ajax_info.txt",true);
     xmlhttp.send();
    }
    </script>
    

jQuery Name Conflicts

jQuery uses the $ sign as a shortcut for jQuery.
Some other JavaScript libraries also use the dollar sign for their functions.
The jQuery noConflict() method specifies a custom name (like jq), instead of using the dollar sign.

<script type="text/javascript">
    var jq=jQuery.noConflict();
    jq("p").hide();
<script>

Caching & Different Ways to cach

Caching is the technique of storing frequently used items in memory so that they can be accessed more quickly. By caching the response, the request is served from the response already stored in memory. It is a technique of temporary storage of page or data on ClientSide or DownStream or Server Side.
  1. Output cache - Full page caching
  2. Fragment caching  - Particular user control
  3. Datacaching  - Small piece of data.
Based upon dependency also there are some classifications
  1. Key
  2. Time
  3. File
  4. SQL Cache
Below are the Possible values for Location Attribute inside OutputCache Page Directive.
  1. Any
  2. None
  3. Client
  4. Downstream
  5. Server
  6. ServerAndClient

AutoEventWireup

  • AutoEventWireup attribute is used to set whether the events needs to be automatically generated or not.
  • The AutoWireup attribute is either set as True or False. The attribute allows you to fire the events written in code behind file.
  • If this page level attribute is set to False then the code behid Events will not fire automatically. For E.g if there is Event for the Page load (Page_load) on code behind file and attribute is set to false then this event will not fire if page loads up in browser.

Maximum number of cookies per site

  • Internet Explorer 6   - 20 cookies 
  • Internet Explorer 8  - 50 cookies 
  • Opera 8.01  30 cookies 
  • Firefox 1.0.6  50 cookies 
Maximum size of a cookie is generally limited to 4KB (4096 bytes)

Event Bubbling

Event Bubbling is nothing but events raised by child controls is handled by the parent control.

Server controls like Datagrid, DataList, Repeater can have other child controls insidethem. Example DataGrid can have combo box inside datagrid. These child control do notraise there events by themselves, rather they pass the event to the container parent (whichcan be a datagrid, datalist, repeater), which passed to the page as “ItemCommand” event.As the child control send there events to parent this is termed as event bubbling

ASP.NET Page Life

  • Pre-Init
  • Init
  • Init Completed
  • Pre-Load
  • Load
  • Load Complete
  • Pre-Render
  • Pre-Render Complete
  • Save State Complete

More info : http://msdn.microsoft.com/en-us/library/ms178472.aspx

HTTP Modules and HTTP Handlers

HTTP modules and HTTP handlers are an integral part of the ASP.NET architecture. While a request is being processed, each request is processed by multiple HTTP modules (for example, the authentication module and the session module) and is then processed by a single HTTP handler. After the handler has processed the request, the request flows back through the HTTP modules.
  • HTTP Handlers
    1. HTTP Handlers can be used to process custom requests that may not be in the standard supported format like .htm, .aspx, .asmx etc.
    2. One example will be RSS feed processing .
    3. The primary job of an Http handler is to produce a http response (not html)
    4. How to configure HTTP handlers
  • HTTP Module
    • Modules are called before and after the handler executes.
    • Modules enable developers to intercept, participate in, or modify each individual request.
    • Modules implement the IHttpModule interface, which is located in the System.Web namespace.
    • How to configure HTTP Modules
More info : http://msdn.microsoft.com/en-us/library/ms972953.aspx

SqlCommand and SqlCommandBuilder


  • SQLCommand is used to execute all kind of SQL queries like DML(Insert, update,Delete) & DDL like(Create table, drop table etc) 
  • SQLCommandBuilder object is used to build & execute SQL (DML) queries like select, insert, update & delete.

ASP.NET Required Access Control Lists

The following table shows which type of file and folder permissions the identity of an ASP.NET Web application must have in order to function properly:
%SystemRoot%\Microsoft.NET\Framework\xxx\Temporary ASP.NET Files Read/write
%SystemRoot%\assembly Read
%SystemRoot%\System32 Read
%SystemRoot%\Temp Read/write/delete
User profile directory Read/write
%SystemRoot%\Microsoft.NET\Framework\xxx and subdirectories Read

More info http://msdn.microsoft.com/en-us/library/kwzs111e.aspx

Web-Garden and Web-Farm

  • Web garden
    1. A Web garden is configured on a single server using multiple processors.
    2. Web garden is configured throw the process model element in the machine.config. 
    3. The cpuMask attributes is used to specifies which processors are eligible to run ASP.NET processes.
    4. The cpuMask value specifies a bit pattern that indicates the CPUs eligible to run ASP.NET threads. For example, the cpuMask hexadecimal value 0x0d represents the bit pattern 1101. On a computer with four CPUs, this indicates that ASP.NET processes can be scheduled on CPUs 0, 2, and 3, but not on CPU 1. ASP.NET launches one worker process for each eligible CPU.
    5. Web gardens enable the use of multiple processes, each process will have its own copy of application state, in-process session state, caches, and static data.
    6. Web gardens should not be used for all applications, especially if they need to maintain state.

  • Web farm
    Web farms use multiple servers for a Web site.

MVC Application on IIS 5.1

  1. Open IIS (Inetmgr from run)
  2. Right click on your Web Site and click Properties
  3. Set permissions to Scripts Only
  4. Click Configuration. Under the Mappings tab, click the Add button
  5. You need to insert the path to the file aspnet_isapi.dll. This is most likely C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll. 
  6. In the Extension field, enter “.*” (excluding quotes).
  7. Select All Verbs. Select “Script Engine”.
  8. Make sure ”Check that file exists” is not selected.

Advantages of a layered architecture

Advantages
  1. Enables develop loosely coupled systems
  2. Application can be independently deployed, maintained, and updated, on different time schedules
  3. Helps you to test the components independently
  4. Multiple applications can reuse the components
Dis-Advantages
  1. Extra overhead of passing through layers instead of calling a component directly
  2. Separating codes leads to complexity to simple applications
Source: http://venkataspinterview.blogspot.com/2011/03/what-are-advantages-and-disadvantages.html

Difference between login controls and Forms authentication

  • The FormsAuthentication class is used in the background for the authentication ticket and ASP.NET membership is used to validate the user credentials.
  • Forms authentication can be easily implemented using login controls without writing any code. Login control performs functions like prompting for user credentials, validating them and issuing authentication just as the FormsAuthentication class.

Dependency Injection

Injecting an instance of a class into a class that depends on it, is called Dependency Injection.

Dependency Injection is of 2 types.
  1. Constructor InjectionConstructor Injection, ensures that all the dependency objects are initialized before we attempt to invoke any methods or peroperties, thus avoiding null reference exceptions.
  2. Setter InjectionSetter Injection, enables you to inject the object, just before you need it. So, if the object is an expensive object to create, and you want to create it as late as possible
What are the advantages of using Dependency Injection?
  1. Dependency Injection allows us to develop very loosely coupled systems.
  2. Easy to swap in a different implementation of a component, as long as the component implements the interface type.
  3. Dependency Injection, allows objects to be mocked with in the Unit Tests. This is the greatest advantage of Dependency Injection.
Source & Example: http://venkataspinterview.blogspot.com/2011/06/explain-dependency-injection-with.html