Response.Redirect

Shashanka Thota 1 Reputation point
2021-07-23T13:10:21.84+00:00

Hi, I have been using as Response.Redirect(Request.Path.ToString(), true); but due to security issues Request.Path.ToString() must not be used directly in redirect method. Could someone tell me better approach to redirect instead of Request.Path.ToString() and hardcoding url.

Developer technologies ASP.NET Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Yijing Sun-MSFT 7,096 Reputation points
    2021-07-26T05:31:09.193+00:00

    Hi @Shashanka Thota ,
    There are two ways to redirect:Server.Transfer and Response.Redirect. I think, Response.Redirect is the best way to redirect.
    Response.Redirect the transfer is done by the browser while with Server.Transfer - it is done on the server.Use Server.Transfer when you want to navigate to pages that are on the same server and use Response.Redirect when you want to navigate between pages that are on different servers / domains.
    Since Response.Redirect have a security concern,it better to use.
    https://stackoverflow.com/questions/30356235/what-is-the-best-approach-for-redirecting-user-in-asp-net
    Best regards,
    Yijing Sun


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our  documentation  to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.