A form is used to pass information from a web browser to
a web server.There are two different ways that a form can be submitted from
your browser to the webserver. In HTML, this is how one would define the
opening form tags for both submission methods: <form
method="GET"> and <form method="POST">.
If a "GET" request is used, the form parameters
are encoded in the URL in what is called a query string.
www.example.com/?login=usetricks@email.com&password=xxyz
In the GET request above, you can see that the form
parameters (login and password) are attached to the end of the URL itself.
A POST request, unlike a GET request, passes the form
parameters in the body of the HTTP request, not in the URL.
Here i am showing the Comparison chart between GET and POST
methods
GET
Method ():
1.form parameters is appended to the URL.
2.Data is not secret it is public.
3.It is a single call system
4.GET is less secure compared to POST because data sent
is part of the URL. So it's saved in browser history and server logs in
plaintext.
5.GET method is visible to everyone (it will be displayed
in the browser's address bar) and has limits on the amount of information to
send.
6.7607 character maximum size.
7.Can be cached.
POST
Method ():
1.form parameters is not appended to the URL.Post Method
passes the form parameters in the body of the HTTP request, not in the URL.
2.Data is secret it is not public in post method.
3.It is a two call system .
4.POST is a little safer than GET because the parameters
are not stored in browser history or in web server logs.
5.POST method variables are not displayed in the URL.
6.8 Mb max size for the POST method.
7.Can not be cached.
Definition -
What does .NET Framework (.NET) mean?
The .NET
framework is a software development framework from Microsoft. It provides a
controlled programming environment where software can be developed, installed
and executed on Windows-based operating systems.
NET
Framework is a complete environment that allows developers to develop, run, and
deploy the following applications:
1-Console
applications
2-Windows
Forms applications
3-Windows
Presentation Foundation (WPF) applications
4-Web
applications (ASP.NET applications)
5-Web services
6-Windows
services
7-Service-oriented
applications using Windows Communication Foundation (WCF)
8-Workflow-enabled
applications using Windows Workflow Foundation (WF)
The .NET Framework has two main components: the
common language runtime (CLR) and .NET Framework class library. The CLR is the
foundation of the .NET framework and provides a common set of services for
projects that act as building blocks to build up applications across all tiers.
It simplifies development and provides a robust and simplified environment
which provides common services to build application. The .NET framework class
library is a collection of reusable types and exposes features of the runtime.
It contains of a set of classes that is used to access common functionality.
In this article i am going to explain How to get/fetch/read current page URL/Address in asp.net using C#.
Here is C#.Net Code to get current page URL/Address in asp.net.
if your page full url is http://example.com/Default.aspx
Here is C#.Net Code to get current page URL/Address in asp.net.
if your page full url is http://example.com/Default.aspx
1-Response.Write(Request.RawUrl);
its output will be : /Default.aspx
2-Response.Write(HttpContext.Current.Request.Url.AbsolutePath);
its output will be : /Default.aspx
3-Response.Write(Request.Url);
its output will be : http://example.com/Default.aspx
4-Response.Write(HttpContext.Current.Request.Url);
its output will be : http://example.com/Default.aspx
5-
Response.Write(Request.Url.AbsoluteUri);
its output will be : http://example.com/Default.aspx
6- Response.Write(HttpContext.Current.Request.Url.AbsoluteUri);
its output will be : http://example.com/Default.aspx
Active Server Pages or Classic ASP, as it is more commonly
known, is Microsoft's first server side scripting engine that enables you to
make dynamic and interactive web pages.
Classic ASP uses server-side scripting to dynamically
produce web pages that are not affected by the type of browser the website
visitor is using.
The default scripting language used for writing ASP is
VBScript, although you can use other scripting languages like JScript
(Microsoft's version of JavaScript).
When a browser requests an ASP Page, the Web server
generates a page with HTML code and sends it back to the browser.Any web pages
containing ASP cannot be run by just simply opening the page in a web browser.
The page must be requested through a web server that supports ASP, this is why
ASP stands for Active Server Pages, no server, no active pages.
This interview section questions contains a brief introduction to the ASP.Net interview Questions in ASP.NET,C#.NET,SQL Server,.NET Framework .NET. The most common question for experience persons .This is Asp.Net Interview Question Part 1.
Here you will get ASP.NET - .NET Interview Questions and Answers.
1. What is ASP?
2. What is ASP.NET?
3. What is the basic difference between ASP and ASP.NET?
4. In which event are the controls fully loaded?
5. How can we identify that the Page is Post Back?
6. What is the lifespan for items stored in ViewState?
7. How information about the user's locale can be accessed?
8. What is the difference between SQL notification and SQL invalidation?
9. Which is the parent class of the Web server control?
10. Can you set which type of comparison you want to perform by the CompareValidator control?
11. What is the behavior of a Web browser when it receives an invalid element?
12. What are the advantages of the code-behind feature?
13. How do you sign out from forms authentication?
14. What is AutoPostBack?
15. What is the function of the ViewState property?
16. Why do you use the App_Code folder in ASP.NET?
17. Define a multilingual Web site.
18. What is an ASP.NET Web Form?
19. What is the difference between a default skin and a named skin?
20. What is IIS? Why is it used?
21. What is Query String? What are its advantages and limitations?
22. What is actually returned from server to the browser when a browser requests an .aspx file and the file is displayed?
23. How can you display all validation messages in one control?
24. Which two new properties are added in ASP.NET 4.0 Page class?
25. What is tracing? Where is it used?
26. What is the difference between authentication and authorization?
27. How can you register a custom server control to a Web page?
28. Which ASP.NET objects encapsulate the state of the client and the browser?
29. Differentiate globalization and localization.
30. What is ViewState?
31. Which method is used to force all the validation controls to run?
32. Which method has been introduced in ASP.NET 4.0 to redirect a page permanently?
33. How can you send an email message from an ASP.NET Web page?
34. What is the difference between the Response.Write() and Response.Output.Write() methods?
35. What does the Orientation property do in a Menu control?
36. Differentiate between client-side and server-side validations in Web pages.
37. How does a content page differ from a master page?
38. Suppose you want an ASP.NET function (client side) executed on the MouseOver event of a button. Where do you add an event handler?
39. What is the default timeout for a Cookie?
40. What are HTTP handlers in ASP.NET?
41. What are the events that happen when a client requests an ASP.NET page from IIS server?
42. Explain file-based dependency and key-based dependency.
43. How can you implement the postback property of an ASP.NET control?
44. Explain how Cookies work. Give an example of Cookie abuse.
45. Explain login controls.
46. What is the use of PlaceHolder control? Can we see it at runtime?
47. What are the event handlers that can be included in the Global.asax file?
48. What is the difference between page-level caching and fragment caching?
49. Describe the complete lifecycle of a Web page.
50. How can you assign page specific attributes in an ASP.NET application?
51. Which method is used to post a Web page to another Web page?
52. What is a Cookie? Where is it used in ASP.NET?
53. What are Custom User Controls in ASP.NET?
54. What does the .WebPart file do?
55. How can you enable impersonation in the web.config file?
56. How can you identify that the page is PostBack?
57. In which database is the information, such as membership, role management, profile, and Web parts personalization, stored?
58. What is State Management? How many ways are there to maintain a state in .NET?
59. What do you understand by aggregate dependency?
60. How can you ensure that no one has tampered with ViewState in a Web page?
61. What is the difference between adding items into cache through the Add() method and through the Insert() method?
62. Explain the cookie less session and its working.
63.What is a round trip?
64.What are the major built-in objects in ASP.NET?
65.Where should the data validations be performed-at the client side or at the server side and why?
67.Why do we need nested master pages in a Web site?
68.How can you dynamically add user controls to a page?
69.What is the appSettings Section in the web.config file?
70.What type of code, client-side or server-side, is found in a code-behind file of a Web page?
71.To which class a Web form belongs to in the .NET Framework class hierarchy?
72.What does the "EnableViewState" property do? Why do we want it On or Off?
73.Which event determines that all the controls are completely loaded into memory?
74.What is the function of the CustomValidator control?
75.What is Role-based security?
76.Which data type does the RangeValidator control support?
77.What are the HTML server controls in ASP.NET?
78.Where is the ViewState information stored?
79.Why a SiteMapPath control is referred to as breadcrumb or eyebrow navigation control?
80.Where is the ViewState information stored?
81.Which namespaces are necessary to create a localized application?
82. What is the difference between an HtmlInputCheckBox control and an HtmlInputRadioButton control?
83. What is the difference between HTML and Web server controls?
84. Explain the AdRotator Control.
85. What is the difference between absolute expiration and sliding-time expiration?
86. What is the code-behind feature in ASP.NET?
87.How can you check if all the validation controls on a Web page are valid and proper?
88.Explain the validation controls. How many validation controls in ASP.NET 4.0?
89.What is difference between a Label control and a Literal control?
90.How many types of Cookies are available in ASP.NET?
91.What is the use of the Global.asax file?
92.What are the Culture and UICulture values?
93.What is the difference between ASP session and ASP.NET session?
94.Which control will you use to ensure that the values in two different controls match?
95. What is the difference between a page theme and a global theme?
96.What do you mean by a neutral culture?
97.What is the use of the <sessionState> tag in the web.config file?
98.Can you post and access view state in another application?
99.Which method do you use to kill explicitly a users session?
100.Which class is inherited when an ASP.NET server control is added to a Web form?
101.What events are fired when a page loads?
102.Write three common properties of all validation controls.
103.What are navigation controls? How many navigation controls are there in ASP.NET 4.0?
104.What are server-side comments?
105.How do you prevent a validation control from validating data at the client end?
106.What is cross-page posting in ASP.NET?
107.Explain the Application and Session objects in ASP.NET.
108.How will you differentiate a submaster page from a top-level master page?
109.What is the difference between a HyperLink control and a LinkButton control?
110.What are the various ways of authentication techniques in ASP.NET?
111.What are the different ways to send data across pages in ASP.NET?
112.What do you mean by the Web Part controls in ASP.NET?
113.What is the use of web.config? What is the difference between machine.config and web.config?
114.Explain the concept of states in ASP.NET.
Asp.Net Interview Questions,
Answer 1
When you are applying any theme to a page, then by default the Default skin applies to all controls of same type to that page. This skin is default for a control if it does not have SkinID attribute. Suppose you create a default skin for a Calendar control, then the control skin applies to all Calendar controls on pages that use the theme.
But the named skin controls have their SkinID property. It is not applying skin attributes automatically for controls by type, but it facilitates to apply explicitly a named skin to a control by changing the control's SkinID property. It allows you to set different skins for different instances of the same control in an application.
Answer 2
The default skin is applied to all the Web server controls in a Web form, which are of similar type, and it does not provide a Skin ID attribute. The named skin provides a Skin ID attribute and users have to set the Skin ID property to apply it.
Tags:ASP.NET interview questions and answers Interview Questions in ASP.NET,C#.NET,SQL Server,.NET.
Sometimes you may have a set of data which always has the same number of characters.
For example a UK landline telephone number has 11 characters.
A length check could be set up to ensure that exactly 11 numbers are entered into the field. This type of validation can't check that the 11 numbers are correct but it can ensure that 10 or 12 numbers aren't entered.
NET validation server control that ensures the number of characters entered and the RegularExpressionValidator can be used to check that a value may require that the number of characters not exceed a certain length.
You can use RegularExpressionValidator for accepting only four digits and RequiredFieldValidator for mandatory checking.Check the below example :
For example a UK landline telephone number has 11 characters.
A length check could be set up to ensure that exactly 11 numbers are entered into the field. This type of validation can't check that the 11 numbers are correct but it can ensure that 10 or 12 numbers aren't entered.
NET validation server control that ensures the number of characters entered and the RegularExpressionValidator can be used to check that a value may require that the number of characters not exceed a certain length.
You can use RegularExpressionValidator for accepting only four digits and RequiredFieldValidator for mandatory checking.Check the below example :
<asp:TextBox ID="txtPinCode"
runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="regExpPinCode" runat="server" ControlToValidate="txtPinCode" ErrorMessage="Must be at least 4 digits" ValidationExpression="\d{11}">
</asp:RegularExpressionValidator>
<asp:RequiredFieldValidator ID="reqFieldPinCode" runat="server" ControlToValidate="txtPinCode" ErrorMessage="Post Code must be entered">
</asp:RequiredFieldValidator>
In this article I am going to explain how to read or write connection strings in web.config file using asp.net .
Write connection strings in web.config file
In this example i will show you how to write connection string in a Web.config file and also i will show you how to read that connection string from Web.config file .
Write connection strings in web.config file
We write connection string inside connectionStrings element.The connectionStrings element is a direct child of the <configuration> element and a peer of the system.web element.
<connectionStrings>
<add
name="MyConString"
connectionString="Data Source=serverName;Initial
Catalog=YourDataBasename;Persist Security Info=True;User
ID=dbuserName;Password=dbpassword"
providerName="System.Data.SqlClient"
/>
</connectionStrings>
Read connection strings from web.config file
After adding connectionString we need to write the some code in our codebehind file to get connection string from web.config.Below is code which we have to write to read connectionString from web.config file.
C# CODE
using System;
using System;
using System.Data.SqlClient;
using System.Configuration;
public partial class dbString : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//the below line will read ConnectionStrings from web.config file.
string dbstrcon = ConfigurationManager.ConnectionStrings["MyConString"].ConnectionString;
//the below line will create new sqlconnection and connection to database by using connection string from web.config file.
SqlConnection mycon = new SqlConnection(dbstrcon);
mycon.Open();
}
}
A Web server serves pages for
viewing in a Web browser, while an application server provides methods that
client applications can call.
A Web server handles HTTP requests, whereas an application
server serves business logic to application programs through any number of
protocols.
The Web server
Web
servers are computers that deliver Web
pages. Every Web server has an IP address and possibly a domain name.A Web
server handles the HTTP protocol. When the Web server receives an HTTP request,
it responds with an HTTP response, such as sending back an HTML page.
The application server
Also called an appserver, and
application server is a program that handles all application operations between
users and an organization's backend business applications or databases. An
application server exposes business logic to client applications through
various protocols, possibly including HTTP. While a Web server mainly deals
with sending HTML for display in a Web browser, an application server provides
access to business logic for use by client application programs. The
application program can use this logic just as it would call a method on an
object (or a function in the procedural world).
ViewState is a very important for the programmers in
page performance point of view. Programmers leave it enable for all the
controls even if there is no need to persist their value. Right use of
ViewState can increase the performance of the page drastically.
Using EnableViewState
property we only have 2 options.
- We can turn off view state altogether.
- Enable viewstate for the entire page and then turn it off on a control-by-control basis.
If you want to turn of ViewState for
the entire page and only enable it for specific controls on the page, then we have
to use ViewStateMode property in conjunction with EnableViewState.
EnableViewState property only accepts true or false values and the default value is true, where as ViewStateMode property can have a value of - Enabled, Disabled and inherit. Inherit is the default value for ViewStateMode property, If we set this then it takes the value from the parent and set it accordingly. Suppose If it has been set to Disabled at Page level and for a checkbox you set ViewStateMode = “Inherit” then it will disable the ViewState for the checkbox.
EnableViewState property only accepts true or false values and the default value is true, where as ViewStateMode property can have a value of - Enabled, Disabled and inherit. Inherit is the default value for ViewStateMode property, If we set this then it takes the value from the parent and set it accordingly. Suppose If it has been set to Disabled at Page level and for a checkbox you set ViewStateMode = “Inherit” then it will disable the ViewState for the checkbox.
ViewStateMode property is introduced
in 4.0, where as EnableViewState exists from a long time.
If
EnableViewState is to True, only then the ViewStateMode settings are applied,
where as, if EnableViewState is set to False then the control will not save its
view state, regardless of the ViewStateMode setting. In short if
EnableViewState is set to False, ViewStateMode setting is not respected.
To
disable view state for a page and to enable it for a specific control on the
page, set the EnableViewState property of the page and the control to true, set
the ViewStateMode property of the page to Disabled, and set the ViewStateMode property of the control to
Enabled.