When we are requesting a new URL through Response.Redirect()
the new page wil open on the new browser window or it wil
open in the same window? If we use Server.Transfer() what
wil happen?



When we are requesting a new URL through Response.Redirect() the new page wil open on the new brow..

Answer / maloy.adhikari

In Both case Same window will open.
I have written the detail diff between two....
.......................................
Server.Transfer vs Response.Redirect:

A common misconception is the difference between
Server.Transfer and Response.Redirect in ASP.NET
applications. Redirect and Transfer both cause a new page to
be processed, but the interaction between the client (web
browser) and server (ASP.NET) is different in each situation.

Redirect: A redirect is just a suggestion – it’s like saying
to the client “Hey, you might want to look at this”. All you
tell the client is the new URL to look at, and if they
comply, they do a second request for the new URL.

If you want to pass state from the source page to the new
page, you have to pass it either on the URL (such as a
database key, or message string), or you can store it in the
Session object (caveat: there may be more than one browser
window, and they’ll all use the same session object).

e.g. Redirect to the page1.aspx page, passing an ID on the
query string. "true" stops processing the current page:

Response.Redirect("page1.aspx?id=100", true);




Transfer: A transfer happens without the client knowing –
it’s the equivalent of a client requesting one page, but
being given another. As far as the client knows, they are
still visiting the original URL.

Sharing state between pages is much easier using
Server.Transfer – you can put values into the Context.Items
dictionary, which is similar to Session and Application,
except that it lasts only for the current request. (search
for HttpContext in MSDN). The page receiving postback can
process data, store values in the Context, and then Transfer
to a page that uses the values.

e.g. Store a message in the context dictionary, and transfer
to the page2.aspx page (which can then display the message):

Context.Items["Message"] = "Your information was changed
successfully";
Server.Transfer("page2.aspx");




Caveats:

* Response.Redirect is more user-friendly, as the site
visitor can bookmark the page that they are redirected to.
* Transferred pages appear to the client as a different
url than they really are. This means that things like
relative links / image paths may not work if you transfer to
a page from a different directory.
* Server.Transfer has an optional parameter to pass the
form data to the new page.
* Since the release version, this no longer works,
because the Viewstate now has more security by default (The
EnableViewStateMac defaults to true), so the new page isn’t
able to access the form data. You can still access the
values of the original page in the new page, by requesting
the original handler:

Is This Answer Correct ?    2 Yes 1 No

Post New Answer

More ASP.NET Interview Questions

When Garbage Collector runs in an Application? 1)Application is running form more than 30 min. 2)On every 1/4th milisecond 3) Randomly 4) Application is running on low of memory

2 Answers   PCS,


What are server side controls?

0 Answers  


What is custom control. What is the difference between custom control and user control ?

1 Answers   Microsoft, Synergy,


Can you explain what inheritance is and an example of when you might use it?

4 Answers   Siebel Systems,


You create an assembly to access data in a relational database. This assembly will be used by several ASP.NET applications on your Web server. You need to ensure that all your applications can access the assembly. Which two actions should you take (Each Answer: presents part of the solution.)? (Choose two) A . Run the Assembly Registration tool (Regasm.exe). B . Run the String Name tool (Sn.exe). C . Run the Installer tool (Intallutil.exe). D . Run the Global Assembly Cache tool (Gacutil.exe).

6 Answers   CPCL, Syntax Softtech,






How can you handle unmanaged code exceptions in asp.net?

0 Answers  


What is cookies in asp net?

0 Answers  


How do active server pages work?

0 Answers  


Define Query Interface,Adref,Release?

1 Answers   Microsoft,


What is the maximum amount of memory any single process on Windows can address? Is this different than the maximum virtual memory for the system? How would this affect a system design?

1 Answers   Infosys, KPIT,


what are the events raised in asp.net page life cycle?in which stage view state can be loaded?

0 Answers   EDS,


Can I tap into other windows livetm services?

0 Answers  


Categories