One of the Frequently asked asp.net interview questions is What are Asp.Net Intrinsic objects
The word intrinsic means properties/attributes of the person/object which are essential and specific to that object or action, and which is wholly independent of any other object, action or consequence.
Asp.net Intrinsic objects or HttpContext objects are
Request, Response, Server, Application, and Session
Detail Ref – MSDN
- Server.Transfer() directly transfers to the another page without round-trip back to the server, saving server resources.
- When we are using Server.Transfer() original url remains same at adddress bar while page is getting changed ( so might be confusing for some times ) so URL History of the page is not chnaged.
- We can’t use server.transfer() for the pages/sites which are not located on the server, we can use Server.Transfer() only for the pages on the same server.
- We can only transfer on aspx pages using Server.Transfer() ,not html/htm pages.
- We can also maintain state while using server.Transfer using HttpContext.Current , we can put/store values to
- HttpContext.Current.Items Dictionary and we can access those values on the next page where we are transferred
HttpContext.Current.Items[“GeneratedQry”] = “Select * from XYZ”;
and we can access it on next page as
string SqlQry = Context.Items[“GeneratedQry”].ToString();
- Server.Transfer() is having one more overload with parameter preserveForm , which is when true preserve the QueryString & Form collections;and when false clear the QueryString and Form collections.
- If preserveForm is true and enableViewStateMac of page is also true then Exception “View State Is Invalid” is getting raised. Because ,When enableViewStateMac is true, ASP.NET runs a message authentication check on the view state of the destination page when the page is posted back from the client and the check will fail. For security purposes, you should keep the enableViewStateMac attribute set to true
Ref – MSDN Support & MSDN
- Response.Redirect() is request from browser for the resource ( the page mentioned ). AS it is request from browser, if the mentioned page is available at the location then browser will generate new request to load the page mentioned causing the 2 server round trips, eventually increase load on server.
- Response.Redirect is slower than Server.Transfer() due to extra server trip.
- When we are using Response.Redirect() we can the new URL changes at adddress bar while page is getting changed as it is actually sever request for the page change or access so URL history of the page changes.
- Using Response.Redirect we can redirect to the page on the different Server also.Response.Redirect can transfer both html & aspx file types.
- Response.Redirect is GET request,so we cant post data from first page to next page , we can maintain state using queryString while using Response.Redirect()
Response.Redirect(“RedirectTest.aspx?ID=” + UserData.UserID));
and we can access it like
string userID = Request[“ID”];
- Response.Redirect is also having one overload with Boolean as an extra parameter
public void Redirect (string url, bool endResponse) when true,
Redirects a client to a new URL. Specifies the new URL and whether execution of the current page should terminate.
- As Response.Redirect is as such new page request for system, it automatically applies all the authentication and authorization logic configured in IIS and ASP.NET code.
Detail Ref – MSDN