Viva- ASP.Net

ASP.NET

1.       How can we identify that the Page is PostBack
 Page object has an “IsPostBack” property, which can be checked to know that is the page posted back
2.       How does ASP.NET maintain state in between subsequent request
ASP.NET has multiple techniques for maintaining state between requests.
The first one is ViewState where a hidden field is added to the form containing serialized data (so stored on the client) and deserialized on postback. This field contains values of ASP.NET controls among others.
Another level is the Session which allows you to persist user related data between multiple requests which is stored on the server (either in memoryor out of process).
Yet another storage is the Cache and the Application where you can store application related data which will be shared among all users. Both are stored on the server.
3.       What is event bubbling?
                Server controls like Data grid, Data List, and Repeater can have other child controls inside them. Example Data Grid can have combo box inside data grid. These child control do not raise there events by themselves, rather they pass the event to the container parent (which can be a data grid, data list, repeater), which passed to the page as “ItemCommand” event. As the child control send events to parent it is termed as event bubbling.

4.       How do we assign page specific attributes
Page attributes are specified using the @Page directive.
5.       Administrator wants to make a security check that no one has tampered with ViewState, how can be ensure this?
Using the @Page directive and setting ‘EnableViewStateMac’ property to True.
6.       What is the use of @ Register directives
@Register directive informs the compiler of any custom server control added to the page
7.       What’s the use of SmartNavigation property
It’s a feature provided by ASP. NET to prevent flickering and redrawing when the page is posted back.
8.       What is AppSetting Section in “Web.Config” file ?
Web.config file defines configuration for a web project. Using “AppSetting” section, we can define user-defined values. Example below defined is “Connection String” section, which will be used through out the project for database connection.
<Configuration>
<appSettings>
<add key="ConnectionString" value="server=xyz;pwd=www;database=testing" />
</appSettings>

9.       Where is ViewState information stored ?
ASP.Net uses HTML Hidden Fields to store ViewState information.
10.   What is the use of @ OutputCache directive in ASP.NET?
It is used for caching.
11.   How can we create custom controls in ASP.NET?
Custom controls are user defined controls. They can be created by grouping existing controls, by deriving the control from System.Web.UI.WebControls.WebControl or by enhancing the functionality of any other custom control. Custom controls are complied into DLL’s and thus can be referenced by as any other web server control. 
Basic steps to create a Custom control:
1. Create Control Library
2. Write the appropriate code
3. Compile the control library
4. Copy to the DLL of the control library to the project where this control needs to be used
5. The custom control can then be registered on the webpage as any user control through the @Register tag.

12.   How many types of validation controls are provided by ASP.NET?

RequiredFieldValidator
RangeValidator
CompareValidator
RegularExpressionValidator
CustomValidator
ValidationSummary


13.   Can you explain what is “AutoPostBack” feature in ASP.NET?
If we want the control to automatically post back in case of any event, we will need to check this attribute as true. Example on a Combo Box change we need to send the event immediately to the server side then set the “AutoPostBack” attribute to true.
14.   How can you enable automatic paging in DataGrid?
Following are the points to be done in order to enable paging in Data grid:-
• Set the “Allow Paging” to true.
• In PageIndexChanged event set the current page index clicked.


protected void GridViewActionItem_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        //AllowPaging="true" PageSize="1"                    OnPageIndexChanging="GridViewActionItem_PageIndexChanging"
        GridViewActionItem.PageIndex = e.NewPageIndex;
        bool res =Convert.ToBoolean(Session["ActionStatusNew"]);
        LoadActionItems(res);
         

    }

15.   What’s the use of “GLOBAL.ASAX” file?
The Global.asax file is an optional file and can be stored in root directory. This File is in accesible for web-sites. This Global.asax file contained in HttpApplicationClass. 
In Global.asax file we can declare global variables like for example the variables used in master pages because same variables can be used for different pages right.It provides more security than others. The Global.asax file is used to handle application-level and session-level events.
 
we donot worry about configuring Global.asax because it is itself configured. Accessing the Global.asax file can not be possible. while one request is in processing it is impossible to
 
send another request, we can not get response for other request and even we can not start a new session. while adding this Global.asax file to our application bydefault it contains five methods,
 
Those methods are:
 
1.Application_Start.
 
2.Application_End.
 
3.Session_Start.
 
4.Session_End.
 
5.Application_Error.
16.   What is the difference between “Web.config” and “Machine.Config” ?
machine.config is a system level configuration i.e it is applied on all application in o/s that the configuration is set where as in web.config it is applicable to only one application i.e each asp.net webapplication will contain atleast on web.config file.


What is the difference between Authentication and authorization?
Authentication is process of identification and verification of web application visitor.
Web application tries to recognize who is the user. For example, ASP.NET application could use Windows authentication or Forms authentication to identify user.
Authorization is process that comes after authentication and means that application is checking if user have rights to access to some part of web application. Very common example is administration area of site. Depending of user rights, application will allow or deny access to specific pages on site.

17.   What’s difference between Datagrid, Datalist and repeater ?
A Datagrid, Datalist and Repeater are all ASP.NET data Web controls. 
They have many things in common like DataSource Property, DataBind Method ItemDataBound and ItemCreated. 
When you assign the DataSource Property of a Datagrid to a DataSet then each DataRow present in the DataRow Collection of DataTable is assigned to a corresponding DataGridItem and this is same for the rest of the two controls also. But The HTML code generated for a Datagrid has an HTML TABLE element created for the particular DataRow and its a Table form representation with Columns and Rows. 
For a Datalist it''''s an Array of Rows and based on the Template Selected and the RepeatColumn Property value We can specify how many DataSource records should appear per HTML row. In hort in datagrid we have one record per row, but in datalist we can have five or six rows per row. 
For a Repeater Control, the Datarecords to be displayed depends upon the Templates specified and the only HTML generated is the due to the Templates. 
In addition to these, Datagrid has a in-built support for Sort, Filter and paging the Data, which is not possible when using a DataList and for a Repeater Control we would require to write an explicit code to do paging.
18.   Does session use cookies?
No, session is stored in server memory.

19.   How can we force all the validation control to run?
Page.Validate

20.   If client side validation is enabled in your Web page, does that mean server side code is not run?
When client side validation is enabled server emit’s JavaScript code for the custom validators. However, note that does not mean that server side checks on custom validators do not execute. It does this redundant check two times, as some of the validators do not support client side scripting.

21.   How can I show the entire validation error message in a message box on the client side?
In validation summary set “ShowMessageBox” to true.
22.   You find that one of your validation is very complicated and does not fit in any of the validators, what will you do?
Best is to go for CustomValidators. Below is a sample code for a custom validator, which checks that a textbox should not have zero value
<asp:CustomValidator id="CustomValidator1" runat="server"
ErrorMessage="Number not divisible by Zero"
ControlToValidate="txtNumber"
OnServerValidate="ServerValidate"
ClientValidationFunction="CheckZero" /><br>
Input:
<asp:TextBox id="txtNumber" runat="server" />
<script language="javascript">
<!--function CheckZero(source, args) {
int val = parseInt(args.Value, 10);
if (value==0) {
args.
IsValid = false;
}
}
// -->
</script>
23.   What is Tracing in ASP.NET?
Tracing allows us to view how the code was executed in detail.
24.   How do we enable tracing?
Tracing is a mechanism to monitor the execution of the application at development as well as in the production (live) environment. In order to demonstrate how to trace an application, we are going to create a sample page.
ASPX PAGE
<%@ page language="C#" trace="true" autoeventwireup="true" codefile="TracePage.aspx.cs"
inherits="TracePage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
Notice that we have kept trace="true" attribute in the Page directives in the above code snippet that enables tracing for this page. 

25.   What exactly happens when ASPX page is requested from Browser?
·         The browser sends the request to the webserver. Let us assume that the webserver at the other end is IIS. 
·         Once IIS receives the request he looks on which engine can serve this request. When I mean engine means the DLL who can parse this page or compile and send a response back to browser. Which request to map to is decided by file extension of the page requested.Depending on file extension following are some mapping ?  
a.     .aspx, for ASP.NET Web pages
b.    .asmx, for ASP.NET Web services
c.     .config, for ASP.NET configuration files
d.    .ashx, for custom ASP.NET HTTP handlers
e.    .rem, for remoting resources
 You can also configure the extension mapping to which engine can route by using the IIS engine.
·         Once IIS passes the request to ASP.NET engine page has to go through two section HTTP module section and HTTP handler section. Both these section have there own work to be done in order that the page is properly compiled and sent to the IIS. HTTP modules inspect the incoming request and depending on that they can change the internalworkflow of the request. HTTP handler actually compiles the page and generates output.
·         Depending on the File extension handler decides which Namespace will generate the output. Example all .ASPX extension files will be compiled by System.Web.UI.PageHandlerFactory. 
·         Once the file is compiled it will be send back again to the HTTP modules and from there to IIS and then to the browser.

26.   How can we kill a user session?
Session.abandon() method
27.   How do you upload a file in ASP.NET?
I will leave this to the readers … Just a hint we have to use System.Web.HttpPostedFile class.

http://www.codeproject.com/Articles/1757/File-Upload-with-ASP-NET http://mohammadnazmul.blogspot.com/2015/02/upload-file-in-aspnet.html

28.   How do I send email message from ASP.NET ?

ASP.NET provides two namespaces System.WEB.mailmessage class and System.Web.Mail.Smtpmail class. Just a small homework create a Asp.NET project and
send a email to your self.(
at mailid@yahoo.com. )
http://csharp.net-informations.com/communications/csharp-smtp-mail.htm
http://www.codeproject.com/Tips/371417/Send-Mail-Contact-Form-using-ASP-NET-and-Csharp

 protected void SendMail()
{
    // Gmail Address from where you send the mail
    var fromAddress = "Gmail@gmail.com";
    // any address where the email will be sending
    var toAddress = YourEmail.Text.ToString(); 
    //Password of your gmail address
    const string fromPassword = "Password";
     // Passing the values and make a email formate to display
    string subject = YourSubject.Text.ToString();
    string body = "From: " + YourName.Text + "\n";
    body += "Email: " + YourEmail.Text + "\n";
    body += "Subject: " + YourSubject.Text + "\n";
    body += "Question: \n" + Comments.Text + "\n";
    // smtp settings
    var smtp = new System.Net.Mail.SmtpClient();
    {
        smtp.Host = "smtp.gmail.com";
        smtp.Port = 587;
        smtp.EnableSsl = true;
        smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
        smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
        smtp.Timeout = 20000;
    }
    // Passing values to smtp object
    smtp.Send(fromAddress, toAddress, subject, body);
}

29.   Explain the differences between Server-side and Client-side code?
Server side code will execute at server end all the business logic will execute at server end where as client side code will execute at client side at browser end.

30.   Can you explain Forms authentication in detail?
 It allows you to create your own list of users and validate their identity when they visit the Web site.
31.   How do I sign out in forms authentication?
FormsAuthentication.Signout ()
32.   If cookies are not enabled at browser end does form Authentication work?
No, it does not work.
33.   What is the difference between “Web farms” and “Web garden”?
Introduction
Web Farms and Web Garden are very common terminology for any production deployment. Though these terms looks same but the things are totally different. Many beginners very confused with these two terms. Here I am giving the basic difference between the Web Farm and Web Garden.
Web Farm
After developing our asp.net web application we host it on IIS Server.  Now one standalone server is sufficient to process ASP.NET Request and response for a small web sites but when the site comes for big organization where there an millions of daily user hits then we need to host the sites on multiple Server. This is called web farms. Where single site hosted on multiple IIS Server and they are  running behind the Load Balancer.









Fig : General Web Farm Architecture
This is the most common scenarios for any web based production environment. Where Client will hit an Virtual IP ( vIP) . Which is the IP address of Load Balancer. When Load balancer received the request based on the server load it will redirect the request to particular Server.
Web Garden
All IIS Request process by worker process ( w3wp.exe). By default each and every application pool contain single worker process. But An application pool with multiple worker process is called Web Garden.   Many worker processes with same Application Pool can sometimes provide better throughput performance and application response time. And Each Worker Process Should have there own Thread and Own Memory space.












There are some Certain Restriction to use Web Garden with your web application. If we use Session Mode to "in proc", our application will not work correctly because session will be handled by different Worker Process. For Avoid this Type of problem we should have to use Session Mode "out proc" and we can use "Session State Server" or "SQL-Server Session State".





http://www.codeproject.com/Articles/23306/ASP-NET-Performance-and-Scalability-Secrets

Comments

Popular posts from this blog

Travel RESUME CV

Tablig