Skip to content

Latest commit

 

History

History
538 lines (310 loc) · 24.8 KB

asp.net.md

File metadata and controls

538 lines (310 loc) · 24.8 KB

ASP.NET

What is ViewData? (Junior)

What is ASP.Net? (Junior)

What is ViewState? (Mid)

How you can add an event handler? (Mid)

What's the use of Response.Output.Write()? (Mid)

What is the difference between ASP.NET and ASP.NET MVC? (Mid)

What is a postback? (Mid)

What is the good practice to implement validations in aspx page? (Mid)

What is the file extension of ASP.NET web service? (Mid)

What is the meaning of Unobtrusive JavaScript? (Senior)

Explain JSON Binding? (Senior)

What are the different types of caching? (Senior)

What are the sub types of ActionResult? (Senior)

How do you register JavaScript for webcontrols? (Senior)

What is the difference between Server.Transfer and Response.Redirect? (Senior)

Where the viewstate is stored after the page postback? (Senior)

How long the items in ViewState exists? (Senior)

What are the different validators in ASP.NET? (Senior)

What is ViewState? How is it encoded? Is it encrypted? Who uses ViewState? (Senior)

List the events in ASP.NET page life cycle (Senior)

Can we add code files of different languages in App_Code folder? (Senior)

How can we prevent browser from caching an ASPX page? (Senior)

In which event of page cycle is the ViewState available? (Senior)

What are the event handlers that we can have in Global.asax file? (Senior)

From which base class all Web Forms are inherited? (Senior)

What is the difference between an HtmlInputCheckBox control and an HtmlInputRadioButton control? (Senior)

In which event are the controls fully loaded? (Senior)

What is the difference between web config and machine config? (Expert)

What is RedirectPermanent in ASP.Net? (Expert)

What are the different Session state management options available in ASP.NET? (Expert)

List the major built-in objects in ASP.NET? (Expert)

Which type if caching will be used if we want to cache the portion of a page instead of whole page? (Expert)

How can we apply Themes to an asp.net application? (Expert)

What are the different types of cookies in ASP.NET? (Expert)

How we can force all the validation controls to run? (Expert)

What is the difference between Web Service and WCF Service? (Expert)

Is it possible to create web application with both webforms and mvc? (Expert)

What is the difference between a web API and a web service? (Expert)

What is Cross Page Posting? (Expert)

What is the equivalent of WebForms in ASP.NET Core? (Expert)

Name some ASP.NET WebForms disadvantages over MVC? (Expert)

What is ViewData? (Junior)

Viewdata contains the key, value pairs as dictionary and this is derived from class — “ViewDataDictionary“. In action method we are setting the value for viewdata and in view the value will be fetched by typecasting.

Source

[↑] Back to top

What is ASP.Net? (Junior)

It is a framework developed by Microsoft on which we can develop new generation web sites using web forms(aspx), MVC, HTML, Javascript, CSS etc. Its successor of Microsoft Active Server Pages(ASP). Currently there is ASP.NET 4.0, which is used to develop web sites. There are various page extensions provided by Microsoft that are being used for web site development. Eg: aspx, asmx, ascx, ashx, cs, vb, html, XML etc.

Source

[↑] Back to top

What is ViewState? (Mid)

View State is the method to preserve the Value of the Page and Controls between round trips. It is a Page-Level State Management technique. View State is turned on by default and normally serializes the data in every control on the page regardless of whether it is actually used during a post-back.

A web application is stateless. That means that a new instance of a page is created every time when we make a request to the server to get the page and after the round trip our page has been lost immediately

Source

[↑] Back to top

How you can add an event handler? (Mid)

** **Using the Attributes property of server side control.

e.g.

btnSubmit.Attributes.Add("onMouseOver","JavascriptCode();")
Source

[↑] Back to top

What's the use of Response.Output.Write()? (Mid)

We can write formatted output using Response.Output.Write().

Source

[↑] Back to top

What is the difference between ASP.NET and ASP.NET MVC? (Mid)

ASP.NET, at its most basic level, provides a means for you to provide general HTML markup combined with server side "controls" within the event-driven programming model that can be leveraged with VB, C#, and so on. You define the page(s) of a site, drop in the controls, and provide the programmatic plumbing to make it all work.

ASP.NET MVC is an application framework based on the Model-View-Controller architectural pattern. This is what might be considered a "canned" framework for a specific way of implementing a web site, with a page acting as the "controller" and dispatching requests to the appropriate pages in the application. The idea is to "partition" the various elements of the application, eg business rules, presentation rules, and so on.

Think of the former as the "blank slate" for implementing a site architecture you've designed more or less from the ground up. MVC provides a mechanism for designing a site around a pre-determined "pattern" of application access, if that makes sense. There's more technical detail to it than that, to be sure, but that's the nickel tour for the purposes of the question.

Source

[↑] Back to top

What is a postback? (Mid)

A postback originates from the client browser. Usually one of the controls on the page will be manipulated by the user (a button clicked or dropdown changed, etc), and this control will initiate a postback. The state of this control, plus all other controls on the page (known as the View State) is Posted Back to the web server.

Source

[↑] Back to top

What is the good practice to implement validations in aspx page? (Mid)

Client-side validation is the best way to validate data of a web page. It reduces the network traffic and saves server resources.

Source

[↑] Back to top

What is the file extension of ASP.NET web service? (Mid)

Web services have file extension .asmx.

Source

[↑] Back to top

What is the meaning of Unobtrusive JavaScript? (Senior)

This is a general term that conveys a general philosophy, similar to the term REST (Representational State Transfer). Unobtrusive JavaScript doesn’t intermix JavaScript code in your page markup.

Eg : Instead of using events like onclick and onsubmit, the unobtrusive JavaScript attaches to elements by their ID or class based on the HTML5 data- attributes.

Source

[↑] Back to top

Explain JSON Binding? (Senior)

JavaScript Object Notation (JSON) binding support started from MVC3 onwards via the new JsonValueProviderFactory, which allows the action methods to accept and model-bind data in JSON format. This is useful in Ajax scenarios like client templates and data binding that need to post data back to the server.

Source

[↑] Back to top

What are the different types of caching? (Senior)

ASP.NET has 3 kinds of caching :

  1. Output Caching,
  2. Fragment Caching,
  3. Data Caching.
Source

[↑] Back to top

What are the sub types of ActionResult? (Senior)

ActionResult is used to represent the action method result. Below are the subtypes of ActionResult:

  • ViewResult
  • PartialViewResult
  • RedirectToRouteResult
  • RedirectResult
  • JavascriptResult
  • JSONResult
  • FileResult
  • HTTPStatusCodeResult
Source

[↑] Back to top

How do you register JavaScript for webcontrols? (Senior)

We can register javascript for controls using Attribtues.Add(scriptname,scripttext) method.

Source

[↑] Back to top

What is the difference between Server.Transfer and Response.Redirect? (Senior)

In Server.Transfer page processing transfers from one page to the other page without making a round-trip back to the client's browser. This provides a faster response with a little less overhead on the server. The clients url history list or current url Server does not update in case of Server.Transfer.

Response.Redirect is used to redirect the user's browser to another page or site. It performs trip back to the client where the client's browser is redirected to the new page. The user's browser history list is updated to reflect the new address.

Source

[↑] Back to top

Where the viewstate is stored after the page postback? (Senior)

ViewState is stored in a hidden field on the page at client side. ViewState is transported to the client and back to the server, and is not stored on the server or any other external source.

Source

[↑] Back to top

How long the items in ViewState exists? (Senior)

They exist for the life of the current page.

Source

[↑] Back to top

What are the different validators in ASP.NET? (Senior)

Client-Side Validation: When validation is done on the client browser, then it is known as Client-Side Validation. We use JavaScript to do the Client-Side Validation.

**Server-Side Validation: ** When validation occurs on the server, then it is known as Server-Side Validation. Server-Side Validation is a secure form of validation. The main advantage of Server-Side Validation is if the user somehow bypasses the Client-Side Validation, we can still catch the problem on server-side.

Source

[↑] Back to top

What is ViewState? How is it encoded? Is it encrypted? Who uses ViewState? (Senior)

View state is a kind of hash map (or at least you can think of it that way) that ASP.NET uses to store all the temporary information about a page - like what options are currently chosen in each select box, what values are there in each text box, which panel are open, etc. You can also use it to store any arbitrary information.

The entire map is serialized and encoded and kept in a hidden variable (__VIEWSTATE form field) that's posted back to the server whenever you take any action on the page that requires a server round trip. This is how you can access the values on the controls from the server code. If you change any value in the server code, that change is made in the view state and sent back to the browser.

Just be careful about how much information you store in the view state, though... it can quickly become bloated and slow to transfer each time to the server and back.

It's not encrypted at all. Just base encoded, which easily reversible.

Source

[↑] Back to top

List the events in ASP.NET page life cycle (Senior)

  1. Page_PreInit
  2. Page_Init
  3. Page_InitComplete
  4. Page_PreLoad
  5. Page_Load
  6. Page_LoadComplete
  7. Page_PreRender
  8. Render
Source

[↑] Back to top

Can we add code files of different languages in App_Code folder? (Senior)

No. The code files must be in same language to be kept in App_code folder.

Source

[↑] Back to top

How can we prevent browser from caching an ASPX page? (Senior)

We can SetNoStore on HttpCachePolicy object exposed by the Response object's Cache property:

Response.Cache.SetNoStore();
Response.Write(DateTime.Now.ToLongTimeString ());
Source

[↑] Back to top

In which event of page cycle is the ViewState available? (Senior)

After the Init() and before the Page_Load().

Source

[↑] Back to top

What are the event handlers that we can have in Global.asax file? (Senior)

  • Application Events: Application_Start , Application_End, Application_AcquireRequestState, Application_AuthenticateRequest, Application_AuthorizeRequest, Application_BeginRequest, Application_Disposed, Application_EndRequest, Application_Error, Application_PostRequestHandlerExecute, Application_PreRequestHandlerExecute,Application_PreSendRequestContent, Application_PreSendRequestHeaders, Application_ReleaseRequestState, Application_ResolveRequestCache, Application_UpdateRequestCache

  • Session Events: Session_Start,Session_End

Source

[↑] Back to top

From which base class all Web Forms are inherited? (Senior)

Page class.

Source

[↑] Back to top

What is the difference between an HtmlInputCheckBox control and an HtmlInputRadioButton control? (Senior)

In HtmlInputCheckBoxcontrol, multiple item selection is possible whereas in HtmlInputRadioButton controls, we can select only single item from the group of items.

Source

[↑] Back to top

In which event are the controls fully loaded? (Senior)

Page load event.

Source

[↑] Back to top

What is the difference between web config and machine config? (Expert)

Web config file is specific to a web application where as machine config is specific to a machine or server. There can be multiple web config files into an application where as we can have only one machine config file on a server.

Source

[↑] Back to top

What is RedirectPermanent in ASP.Net? (Expert)

RedirectPermanent Performs a permanent redirection from the requested URL to the specified URL. Once the redirection is done, it also returns 301 Moved Permanently responses.

Source

[↑] Back to top

What are the different Session state management options available in ASP.NET? (Expert)

  • In-Process stores the session in memory on the web server.
  • Out-of-Process Session state management stores data in an external server. The external server may be either a SQL Server or a State Server. All objects stored in session are required to be serializable for Out-of-Process state management.
Source

[↑] Back to top

List the major built-in objects in ASP.NET? (Expert)

  • Application
  • Request
  • Response
  • Server
  • Session
  • Context
  • Trace
Source

[↑] Back to top

Which type if caching will be used if we want to cache the portion of a page instead of whole page? (Expert)

Fragment Caching: It caches the portion of the page generated by the request. For that, we can create user controls with the below code:

<%@ OutputCache Duration="120" VaryByParam="CategoryID;SelectedID"%>
Source

[↑] Back to top

How can we apply Themes to an asp.net application? (Expert)

We can specify the theme in web.config file.

Source

[↑] Back to top

What are the different types of cookies in ASP.NET? (Expert)

  • Session Cookie - Resides on the client machine for a single session until the user does not log out.
  • Persistent Cookie - Resides on a user's machine for a period specified for its expiry, such as 10 days, one month, and never.
Source

[↑] Back to top

How we can force all the validation controls to run? (Expert)

The Page.Validate() method is used to force all the validation controls to run and to perform validation.

Source

[↑] Back to top

What is the difference between Web Service and WCF Service? (Expert)

  • Web Service is based on SOAP and return data in XML form. It support only HTTP/S protocol. It is not open source but can be consumed by any client that understands xml. It can be hosted only on IIS.

  • WCF is also based on SOAP and return data in XML form. It is the evolution of the web service(ASMX) and support various protocols like TCP, HTTP, HTTPS, Named Pipes, MSMQ. The main issue with WCF is, its tedious and extensive configuration. It is not open source but can be consumed by any client that understands xml. It can be hosted with in the applicaion or on IIS or using window service.

Source

[↑] Back to top

Is it possible to create web application with both webforms and mvc? (Expert)

Yes. We have to include below mvc assembly references in the web forms application to create hybrid application.

  • System.Web.Mvc
  • System.Web.Razor
  • System.ComponentModel.DataAnnotations
Source

[↑] Back to top

What is the difference between a web API and a web service? (Expert)

  • A web service typically offers a WSDL from which you can create client stubs automatically. Web Services are based on the SOAP protocol.

  • ASP.NET Web API is a newer Microsoft framework which helps you to build REST based interfaces. The response can be either JSON or XML, but there is no way to generate clients automatically because Web API does not offer a service description like the WSDL from Web Services.

Source

[↑] Back to top

What is Cross Page Posting? (Expert)

When we click submit button on a web page, the page post the data to the same page. The technique in which we post the data to different pages is called Cross Page posting. This can be achieved by setting POSTBACKURL property of the button that causes the postback. Findcontrol method of PreviousPage can be used to get the posted values on the page to which the page has been posted.

Source

[↑] Back to top

What is the equivalent of WebForms in ASP.NET Core? (Expert)

ASP.NET Core Razor Pages is the modern equivalent to "Classic ASP.NET Web Forms." Razor Pages is a new aspect of ASP.NET Core MVC that makes coding page-focused scenarios easier and more productive.

Source

[↑] Back to top

Name some ASP.NET WebForms disadvantages over MVC? (Expert)

MVC is almost ALWAYS the better solution. There is why:

  • The page lifecylce is simpler and more efficient
  • There is no such thing as controls besides html controls. You don't need to debug your output to see what ASP .Net is generating.
  • ViewModels give you immense power and obviate the need to do manual control binding and it eliminates many errors relating to binding.
  • You can have multiple forms on a page. This was a serious limitation of WebForms.
  • The web is stateless and MVC matches the architecture of the web more closely. Webforms introduces state and the bugs you have with it by introducing the ViewState. The ViewState is automatic and works in the background, so it doesn't always behave the way you want it to.
  • Web applications need to work with ajax these days. It's not acceptable to have full page loads any more. MVC makes ajax so so much better, easier and more efficient with JQuery.
  • Because you can have multiple forms on a page, and because the architecture is driven by calls to urls, you can do funky things like ajax load a different form, like an edit form into your current page using JQuery. Once you realise what this lets you do you can do amazing things easily.
  • ASP.Net WebForms is not only an abstraction over html, it is an extremely complex one. Sometimes you would get a weird bug and struggle with it for much longer than need be. In many cases you could actually see what it was doing wrong but you are unable to do anything about it. You end up doing weird workarounds.
  • WebForms does not make a good technology for designers. Designers often like working with html directly. In MVC it's a view, in WebForms it's half a day of work.
  • As the web platform is evolving fast WebForms wont keep up. It's not aware of new tags or features of HTML5, it will still render the same stuff unless you get (often) expensive 3rd party controls or wait for Microsoft to issue an update.
  • Controls in WebForms limit you in so many ways. In MVC you can just grab a JQuery library and integrate it into your templates.
Source

[↑] Back to top