Monday 20 February 2017

ASP.NET interview questions Part-4

1. Ques: What is the difference between WCF  and web services? 
Answer:
Windows Communication Foundation : (WCF) is a framework for building service-oriented applications. Using WCF, you can send data as asynchronous messages from one service endpoint to another. It is framework to make inter-process communication easier like web services, Remoting, MS Message Queuing,
  • It can be hosted in many form like IIS, windows activation service, Self-hosting, Windows service 
  • One-Way, Request-Response, Duplex are different type of operations supported in WC.
  • System.Runtime.Serialization namespace is used for serialization.
  • Can be accessed through HTTP, TCP, Named pipes, MSMQ, Pear to pear .
  • Supports multi-threading by using ServiceBehaviour class.
  • Security, Reliable messaging, Transactions.
  • WCF are faster than Web Services.
  • Supports various protocols like HTTP, HTTPS, TCP, Named Pipes and MSMQ.
  • ServiceContract and OperationContract attributes are used for defining WCF service.

Web Services: A Web Service is programmable application logic accessible via standard web protocols. One of these web protocols is the Simple Object Access Protocol (SOAP).

  • It can be hosted in IIS Only.
  • One-way, Request- Response are the different operations supported in web service.
  • System.Xml.serialization name space is used for serialization.
  • Can be accessed through HTTP, TCP, Custom.
  • Support security but is less secure as compared to WCF.
  • Web Services are slower than WCF.
  • Doesn’t support multi-threading.
  • Supports only HTTP, HTTPS protocols.
  • WebService and WebMethod attributes are used for defining web service.

2. Ques: Difference between HttpGet and HttpPost requests?
Answer:
GET Request:-
Data is submitted as a part of url.
Data is visible to the user as it posts as query string.
It is not secure but fast and quick.
It can be cached.
GET requests remain in the browser history.
GET requests can be bookmarked.
GET requests should never be used when dealing with sensitive data.
GET requests have length restrictions.
GET requests should be used only to retrieve data.

POST Request:-
Data is submitted in http request body.
Data is not visible in the url.
It is more secured but slower as compared to GET.
It can not be cached.
POST requests do not remain in the browser history.
POST requests cannot be bookmarked.
In this no restrictions on data length.


3. Ques: What is difference between file-based dependency and key-based dependency ?
Answer:
file-based dependency:-  file-based dependency, the dependency is on a file saved in a disk.
key-based dependency:- In key-based dependency, It depend on another cached item.


4. Ques: What are the various types of validation controls provided by ASP.NET?
Answer:
ASP.NET provides 6 types of validation controls

1. RequiredFieldValidator - It is used when Use does not want the filed to be empty. It checks if the control has any value or not.
2. RangeValidator - It checks if the value in validated control is within the specified range or not.
3. CompareValidator -It checks if the value in controls matches  specific values or not.
4. RegularExpressionValidator -It checks if the value matches a specific regular expression or not.
5. CustomValidator -It Used to define User Defined validation.
6. Validation Summary - Displays summary of all current validation errors on an ASP.NET page.


5. Ques: What is the Global.asax.cs used for?
Answer:
The Global.asax.cs is used to implement application and session level events in asp.net application.


6. Ques: What is the difference between server.transfer and response.redirect in asp.net ?
Answer:

Response.Redirect 
  • In this redirect the request to some plain HTML pages on our server or to some other web server
  • we don't care about causing additional roundtrips to the server on each request.
  • we do not need to preserve Query String and Form Variables from the original request.
  • we want our users to be able to see the new redirected URL where he is redirected in his browser (and be able to bookmark it if its necessary).
Server.Transfer
  • In this transfer current page request to another .aspx page on the same server.
  • we want to preserve server resources and avoid the unnecessary roundtrips to the server.
  • we want to preserve Query String and Form Variables (optionally).
  • we don't need to show the real URL where we redirected the request in the users Web Browser.

7. Ques:  What is Scavenging?
Answer:
It is the process of deleting items from the cache when memory is scarce. Items are removed when they have not been accessed in some time or when items are marked as low priority when they are added to the cache. ASP.NET uses the CacheItemPriority object to determine which items to scavenge first. CacheItemPriority.High assigns a priority level to an item so that the item is least likely to be deleted from the cache.


8. Ques:  What is Cross Page Posting? How is it done?
Answer:
Cross page postback is the concept which is used to submit one page (Default.aspx) controls to another page (Default2.aspx) and access those page (Default.aspx) control values in another page (Default2.aspx).
                By default, ASP.NET submits a form to the same page. In cross-page posting, the form is submitted to a different page. This is done by setting the ‘PostBackUrl’ property of the button(that causes postback) to the desired page. In the code-behind of the page to which the form has been posted, use the ‘FindControl’method of the ‘PreviousPage’ property to reference the data of the control in the first page.


9. Ques: What are Master Pages?
Answer:
ASP.NET master pages allow you to create a consistent layout for the pages in your application. A single master page defines the look and feel and standard behavior that you want for all of the pages (or a group of pages) in your application.

  • Master pages is a template that is used to create web pages with a consistent layout throughout your application.
  • Master Pages contains content placeholders to hold page specific content.
  • When a page is requested, the contents of a Master page are merged with the content page, thereby giving a consistent layout.

No comments:

Post a Comment

Thank you for comment