We are providing online training of realtime Live project on Asp.Net MVC with Angular and Web API. For more information click here. If you have any query then drop the messase in CONTACT FORM

Monday, June 29, 2015

Interview Questions on ASP.NET Page navigation techniques

What are the different page navigation techniques in ASP.NET? 

Hyperlink control: Navigate to another page.
Response.Redirect : Navigate to another page from code. This is equivalent to clicking a hyperlink.
Server.Transfer : End the current Web form and begin executing a new Web form. This method works only when navigating to a Web Forms page (.aspx).
Server.Execute : Begin executing a new Web form while still displaying the current Web form. The contents of both forms are combined. This method works only when navigating to a Web Forms page (.aspx).
Window.Open script method : Display a page in a new browser window on the client.

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

  • When we use Server.Transfer the redirection happens on the server whereas when we use Response.Redirect the redirection happens from the browser.
  • Server.Transfer is faster as there is no round trip involved while navigating from one webform to another webform.Response.Redirect is slower than Server.Transfer as there is a round trip from the server to the client browser.
  • Server.Transfer works only with .aspx files whereas Response.Redirect works with .aspx and .Htm pages.
  • Server.Transfer will work with files on the same web server. You can't use Server.Transfer to send the user to an external site where as Response.Redirect can do that.
  • Server.Transfer does not update the URL in the browser. For example when you navigate from WebForm1.aspx to WebForm2.aspx using Server.Transfer the URL in the browser still shows WebForm1.aspx while you are actually looking at WebForm2.aspx. Response.Redirect updates the URL in the browser.
What is the use of Server.Execute method?
Server.Execute method is used to process a second Web form without leaving the first Web form. This technique lets you direct the results from a Web form to a region on the current page.


Is it possible to send a webform's QueryString, ViewState, and event procedure information to another webform? 
Yes, we can use Server.Transfer or Server.Execute to send a webform's QueryString, ViewState, and event procedure information to another web form.

For this to work, you have to set the preserveForm argument to True. To be able to read one Web form’s ViewState from another, you must first set the EnableViewStateMac attribute in the Web form’s Page directive to False. By default, ASP.NET hashes ViewState information, and setting this attribute to False disables that hashing so that the information can be read on the subsequent Web form.

No comments: