Which one is better, Server.Transfer or Response.Redirect? I am looking for some explanation for this.
Which one is better Server.Transfer and Response.Redirect
3.2k views Asked by Student At
2
There are 2 answers
1
mcyalcin
On
They have different functions. Definition of better depends on what you are trying to do.
Response.Redirect tells the client to visit a new address, which can be anywhere.
Server.Transfer forwards the request (optionally preserving the query string) to another page on the same server.
If your criterion is cutting unnecessary overhead given that the new page is on the same server, Server.Transfer is the method you want.
Related Questions in ASP.NET
- Implementing Azure AD B2C Authentication in .NET 8 Blazor Project (RenderMode: InteractiveAuto)
- Azure Application Insights Not Displaying Custom Logs for Azure Functions with .NET 8
- IIS Rewrite Module exclude bots but allow GoogleBot
- Angular 16 sending null values to API
- I am the domain admin, newbie, how do I connect youtube.com on my domain?
- Dropdown list showing SQLServer2005SQLBrowserUser$DONSERVER instead of Active Directory group name in ASP.NET MVC C#
- ASP.NET Identity, Losing Ability to Login until Application Pool Recycles
- How to unprotect ASP.NET FormAuthentication cookie
- How does it work using ASP.NET FormAuthentication
- What is the purpose of a completely standalone 'this'?
- Is there a way to read .csproj PropertyGroup variable in c#
- MSBuild trying to copy different dll with similar name into project sporadically
- Minimizing IdentityServer4 Round Trips in Microservice Architecture with Ocelot
- Azure AD guest account in web app authentication user claims data
- Receiving 400 bad request on post when customer auth handler is used
Related Questions in PERFORMANCE
- Upsert huge amount of data by EFCore.BulkExtensions
- How can I resolve this error and work smoothly in deep learning?
- Efficiently processing many small elements of a collection concurrently in Java
- Theme Preloader for speed optimization in WordPress
- I need help to understand the time wich my simple ''hello world'' is taking to execute
- Non-blocking state update
- Do conditional checks cause bottlenecks in Javascript?
- Performance of sketch drastically decreases outside of the P5 Web Editor
- sample query for review for improvement on big query
- Is there an indexing strategy in Postgres which will operate effectively for JOINs with ORs
- Performance difference between two JavaScript code snippets for comparing arrays of strings
- C++ : Is there an objective universal way to compare the speed of iterative algorithms?
- How to configure api http request with load testing
- the difference in terms of performance two types of update in opensearch
- Sveltekit : really long to send the first page and intense CPU computation
Related Questions in RESPONSE.REDIRECT
- nextjs redirect of route handling not working
- When we redirect page in asp.net it seems to cache the URL and won't redirect to new URL
- Cannot redirect in Next.js 13 using res.redirect()
- Unable to redirect to external URL from Java
- return res.redirect() not working in expressJs
- Unable to set a cookie with "sameSite: none" and "secure: true" attributes while redirecting with ExpressJs
- Google redirect to a page like http://my-website.s3-website-eu-west-1.amazonaws.com/#/callback
- Secure site redirect to non secure default.aspx
- Why does a permanent redirect has cache enabled but a temporary redirect doesn't have a cache?
- dropdown selected item and repose.redirect
- How do I get my django code to redirect users accordingly
- res.redirect keeps getting called multiple times but doesnt redirect
- Visual Basic - How to open a url on a new tab of browser in ASP.NET web forms?
- ASP.NET: Response.Redirect() with root-relative URL (tilde, ~) repeats subfolder in path (after migrating from target framework 3.5 to 4.5)
- Asp.net - scroll goes to the top when redirecting querystring
Related Questions in SERVER.TRANSFER
- Button Click Not Working after Server.Transfer() method
- WebForm Server.Transfer - Variables are not being recorded in downloaded files
- Server.Transfer Issues
- Server.Transfer, Response.Redirect, and ApplicationInstance.CompleteRequest work around in ASP.Net
- How do i call an aspx page from within another aspx page and not wait for it to complete?
- How can I do Server.Transfer() to get Web2 site Page from Web1 site
- ASP.NET - Server.Transfer with url in browser updated
- Chrome fails to load resources when using Server.Transfer or Response.Redirect
- Wrong usage of UserHostAddress
- Server.TransferRequest doesn't send passed header
- redirection from one user control to another user control
- How can I server.transfer to one page and then server.transfer back to the original
- Server.transfer postback issue
- Open Cart Multi Store Url Issue after transferring to another domain
- HttpContext.Server.Transfer to an IHttpHandler
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
It depends on your reqiremnts.
Suppose if you are on page1.aspx and wants to go to page2.aspx
Response.Redirect scenario
page1.aspx calls Response.Redirect("page2.aspx",false); which sends a 302 redirect header down to the client browser, telling it that the requested (page1.aspx) has moved to page2.aspx, and the web application terminates. The client browser then sends a request to the webserver for page2.aspx. IIS tells asp_wp.exe to process the request. asp_wp.exe (after checking authentication and doing all the other setup stuff it needs to do when a new request comes in) instantiates the appropriate class for page2.aspx, processes the request, sends the result to the browser, and shuts down. In this case there is a roundtrip to the server.
Server.Transfer scenario
page1.aspx calls Server.Transfer("page2.aspx");. ASP.NET instantiates the appropriate class for page2.aspx, processes the request, sends the result to the browser, and shuts down.
Note that Server.Transfer cuts the load on the client and the server.
Server.Transfer is easier to code for, too, since you maintain your state. Information can be passed through the HTTP Context object between the pages, eliminating the need to pass information in the querystring or reload it from the database.
Some limitations of Server.Transfer
It can only work for same domain pages (on same server)
It bypasses any authentication on the page you transfer to
Now you can take decision yourself which one is better according to your requirements.