0% found this document useful (0 votes)
35 views

Question Answer

The document discusses ASP.NET, which is a web framework used to develop websites, web applications, and web services. It provides advantages like separation of concerns, reduced coding time, and out-of-the-box features. ASP.NET validation controls validate user input data. Session state management stores client data on the server for each user across multiple pages. Caching in ASP.NET stores frequently used data in memory to improve performance.

Uploaded by

peter77
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Question Answer

The document discusses ASP.NET, which is a web framework used to develop websites, web applications, and web services. It provides advantages like separation of concerns, reduced coding time, and out-of-the-box features. ASP.NET validation controls validate user input data. Session state management stores client data on the server for each user across multiple pages. Caching in ASP.NET stores frequently used data in memory to improve performance.

Uploaded by

peter77
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Q1. What is ASP.NET? Explain its advantages in detail.

Also Explain the different


validators in ASP.NET.

Answer:

It is a web framework designed and developed by Microsoft.

It is used to develop websites, web applications and web services.

It provides fantastic integration of HTML, CSS and JavaScript. It was first released in
January 2002.

It is built on the Common Language Runtime (CLR) and allows programmers to write code
using any supported .NET language.

ASP.NET provides three development styles for creating web applications:

1. Web Forms
2. ASP.NET MVC
3. ASP.NET Web Pages

Advantage

1) It allows for separation of concern


2) Reduces coding time
3) Consists of some of out-of- the box features
4) World class toolbox
5) Delivers power and flexibility
6) Simplicity
7) Customizability and Extensibility
8) Security
9) Manageability
10) Benefit of continuous monitoring
11) Cross-platform migration
Disadvantages

1) Security
Yes, we did mention security as one of the advantages of the framework. But
apparently, extra care should be taken to protect the applications.
2) Costly
3) Documentation is not exactly up to the mark
4) ASP.NET core not good enough
5) Making changes in the app
Changes might not work in the next version of your app. What works in the current
version, works, but in the next, you might have to get help from GitHub.
6) Porting ASP application from one server to another is expensive

ASP.NET - Validators

ASP.NET validation controls validate the user input data to ensure that useless,
unauthenticated, or contradictory data don't get stored.

ASP.NET provides the following validation controls:

 RequiredFieldValidator
 RangeValidator
 CompareValidator
 RegularExpressionValidator
 CustomValidator
 ValidationSummary

RequiredFieldValidator Control

The RequiredFieldValidator control ensures that the required field is not empty. It is
generally tied to a text box to force input into the text box.

The syntax of the control is as given:

<asp:RequiredFieldValidator ID="rfvcandidate"
runat="server" ControlToValidate ="ddlcandidate"
ErrorMessage="Please choose a candidate"
InitialValue="Please choose a candidate">

</asp:RequiredFieldValidator>

RangeValidator Control

The RangeValidator control verifies that the input value falls within a predetermined range.

It has three specific properties:

Properties Description
It defines the type of the data. The
Type available values are: Currency, Date,
Double, Integer, and String.

It specifies the minimum value of the


MinimumValue
range.

It specifies the maximum value of the


MaximumValue
range.

The syntax of the control is as given:

<asp:RangeValidator ID="rvclass" runat="server" ControlToValidate="txtclass"


ErrorMessage="Enter your class (6 - 12)" MaximumValue="12"
MinimumValue="6" Type="Integer">

</asp:RangeValidator>

CompareValidator Control

The CompareValidator control compares a value in one control with a fixed value or a value
in another control.

It has the following specific properties:

Properties Description

Type It specifies the data type.

It specifies the value of the input


ControlToCompare
control to compare with.

It specifies the constant value to


ValueToCompare
compare with.

It specifies the comparison operator,


the available values are: Equal,
NotEqual, GreaterThan,
Operator
GreaterThanEqual, LessThan,
LessThanEqual, and
DataTypeCheck.

The basic syntax of the control is as follows:

<asp:CompareValidator ID="CompareValidator1" runat="server"


ErrorMessage="CompareValidator">
</asp:CompareValidator>

RegularExpressionValidator

The RegularExpressionValidator allows validating the input text by matching against a


pattern of a regular expression. The regular expression is set in the ValidationExpression
property.

The syntax of the control is as given:

<asp:RegularExpressionValidator ID="string" runat="server" ErrorMessage="string"


ValidationExpression="string" ValidationGroup="string">

</asp:RegularExpressionValidator>

CustomValidator

The CustomValidator control allows writing application specific custom validation routines
for both the client side and the server side validation.

The basic syntax for the control is as given:

<asp:CustomValidator ID="CustomValidator1" runat="server"


ClientValidationFunction=.cvf_func. ErrorMessage="CustomValidator">

</asp:CustomValidator>

ValidationSummary
The ValidationSummary control does not perform any validation but shows a summary of all
errors in the page. The summary displays the values of the ErrorMessage property of all
validation controls that failed validation.

The following two mutually inclusive properties list out the error message:

 ShowSummary : shows the error messages in specified format.


 ShowMessageBox : shows the error messages in a separate window.

The syntax for the control is as given:

<asp:ValidationSummary ID="ValidationSummary1" runat="server"


DisplayMode = "BulletList" ShowSummary = "true" HeaderText="Errors:" />
Question 2 : What are the different session state management option
available in ASP.NET? Explain Caching in ASP.NET.
Answer:

Types of State Management in ASP.NET

There are two types of State management in ASP net. They are :

 Server-side
 Client-side
These are further subdivided into the following -

Server-Side

 Session
 Application
 Cache

Client-Side

 Cookies
 Viewstate
 Control state
 Query String
 Hidden Field

Session State Management in ASP.Net


 State management is a important part of any application.
 The Session is the important features of asp.net.
 Session state is a period of time to visit a website for a particular user.
 Session can store the client data on a server.
 Session is a best state management features to store the client data on server
separately for each user.
 Session can store value across on multiple pages of website.
 Viewstate can store value on single page.

 Session value can be accessible from all pages from website.


 We can store some information in session in one page and can access same information
on rest of all page by using session.
 By default, Session state is enabled for all ASP.NET
applications.

Let’s understand session using example.


Syntax of session

Session[“session_name”] = “session value”;

Declare session in asp.net

Session[“name”]=”Meera Academy”;
Response.Redirect(“nextpage.aspx”);

Retrieve session value on other page

string myvalue= Session[“name”].ToString();


Response.Write(“Name = ” + myvalue);

C# code for set session value on first page “default.aspx” on button click events. After
assigning a value to session we redirect to other page “next.aspx” using response.redirect
method. Here, we assign textbox name value to Session[“name”] and city value to
Session[“city”] and redirect to next.aspx page.
protected void btnsession_Click(object sender, EventArgs e)
{
Session["name"] = txtname.Text;
Session["city"] = txtcity.Text;

Response.Redirect("next.aspx");
}
On “next.aspx” page we retrieve and display session value on web page using label control.
C# code on “next.aspx” page for retrieve session value.

protected void btngetvalue_Click(object sender, EventArgs e)


{
lblname.Text = Session["name"].ToString();
lblcity.Text = Session["city"].ToString();
}

Caching in ASP.NET

 Caching is a technique of storing frequently used data/information in memory, so that,


when the same data/information is needed next time, it could be directly retrieved from
the memory instead of being generated by the application.
 Caching is extremely important for performance boosting in ASP.NET, as the pages and
controls are dynamically generated here.
 It is especially important for data related transactions, as these are expensive in terms of
response time.
 Caching places frequently used data in quickly accessed media such as the random
access memory of the computer.
 The ASP.NET runtime includes a key-value map of CLR objects called cache.
 This resides with the application and is available via the HttpContext and
System.Web.UI.Page.
The data will not be available in the following cases:

 If its lifetime expires,


 If the application releases its memory,
 If caching does not take place for some reason.
Caching in ASP.Net

ASP.NET provides the following different types of caching:

 Output Caching : Output cache stores a copy of the finally rendered HTML pages or
part of pages sent to the client. When the next client requests for this page, instead of
regenerating the page, a cached copy of the page is sent, thus saving time.
 Data Caching : Data caching means caching data from a data source. As long as the
cache is not expired, a request for the data will be fulfilled from the cache. When the
cache is expired, fresh data is obtained by the data source and the cache is refilled.
 Object Caching : Object caching is caching the objects on a page, such as data-bound
controls. The cached data is stored in server memory.
 Class Caching : Web pages or web services are compiled into a page class in the
assembly, when run for the first time. Then the assembly is cached in the server. Next
time when a request is made for the page or service, the cached assembly is referred
to. When the source code is changed, the CLR recompiles the assembly.
 Configuration Caching : Application wide configuration information is stored in a
configuration file. Configuration caching stores the configuration information in the
server memory.

Output Caching

Syntax for OutputCache directive:

<%@ OutputCache Duration="15" VaryByParam="None" %>

Object Caching

Cache["key"] = item;
Question 3: What are the concept of Globalization and Localization in .NET ? Explain Web
Config File in ASP.

In the context of software development and the .NET framework, globalization and
localization are two important concepts that deal with making applications adaptable to
different cultures, languages, and regions.

1. Globalization: Globalization refers to the process of designing and developing software


applications in a way that allows them to be used in multiple cultures or regions without
requiring modification. It involves making the application culture-neutral or culture-agnostic,
so it can handle various languages, date formats, number formats, and other cultural
differences.
In .NET, globalizing an application involves:
 Cultural Awareness: Writing code that is aware of and can adapt to different
cultures.
 Resource Management: Storing localized resources (strings, images, etc.) separately
from the code to facilitate easy translation and adaptation.
 Date and Number Formatting: Using culture-specific formatting for dates,
numbers, and currencies.
 Unicode Support: Ensuring proper support for Unicode characters to accommodate
different languages.
.NET provides classes and APIs to support globalization, such as the CultureInfo class,
resource files, and the System.Globalization namespace.

2. Localization: Localization is the process of customizing an application for a specific culture


or locale. It involves adapting the application's user interface, content, and other elements to
meet the linguistic and cultural expectations of a particular target audience. Localization
typically includes translating text, adjusting date and time formats, and handling other region-
specific requirements.
In .NET, localizing an application involves:
 Resource Files: Creating separate resource files for each supported language to store
localized strings and other resources.
 Satellite Assemblies: Compiling the localized resources into satellite assemblies,
which can be easily swapped to change the language of the application.
 Cultural-specific Adjustments: Adapting the application's UI and behavior based on
the specific requirements of different cultures.
.NET supports localization through the use of satellite assemblies, resource files, and features
in the System.Resources namespace.

Web config Files in ASP.NET


 The Web config files are the configuration files in your website that manage the
various settings in your web application.
 These settings are generally stored in form of XML and these settings are separate
from your web application code.
 From this way, you can easily update your web settings on your XML file.
 Generally, a website contains a single web.config file but if your application requires
a different settings for your different directory then you can easily add according to
your need in all directories.

Why Configuration File?


Configuration file in the website describe the properties & behaviour of your Web
Application.
 These files manage many settings related to your website. The web configuration are
the XML files with the extension of .config.
 These are the normal text files which can be edited by any of the editors like Notepad,
VS code Sublime etc. and they are in the readable forms for the Developer.
Benefits of XML Configuration Files-
 1.) Web config Files in ASP.NET are used to store the specific information of
websites and retrieve them easily. These are in a human readable form.
 2.) If you have made any changes, it does not require restart of the server. These
changes will automatically reflect after saving your file on the system.
 3.) You can use any text editor or XML parser to create or edit the ASP.NET
Configuration files.

Settings in Web.config files-


There are the number of Web.config settings which we define while developing an
application:
1.) Database Connection are the most common settings in the Configuration Files.
2.) Error Handling while any HTTP Client Server error occur or while REQUESTED
PAGE NOT FOUND error has occur these help the user to handle all the inappropriate
request.
3.) Session State in the application for storing the value which were used in entire page of the
application.
4.) Caching Settings are the one of the most important setting to speed up your web
applications. They are used to store the code snippets. So that the website can load faster.
Syntax
<configSections>
<section />
<sectionGroup />
<remove />
<clear/>
</configSections>

Example:

1.

<configuration>
<appSettings>
<add key="Application Name" value="MyApplication" />
</appSettings>
</configuration>
2.

<configuration>
<appSettings>
<add key="appISBN" value="0-273-68726-3" />
<add key="appBook" value="Corporate Finance" />
</appSettings>
</configuration>
3.

<connectionStrings>
<add name="name"
connectionString="Constring"
providerName="System.Data.OleDb" />
</connectionStrings>

You might also like