locked
Using reponse.redirect("www.mycomany.com") to open company home page is the good way? RRS feed

  • Question

  • User546194788 posted

    In a button, using reponse.redirect("www.mycomany.com") to open company home page is the good way?

    If not, please let me know the another way.

    Thursday, July 16, 2020 4:52 PM

All replies

  • User475983607 posted

    aspfun

    In a button, using reponse.redirect("www.mycomany.com") to open company home page is the good way?

    If not, please let me know the another way.

    Or a standard link...

    <a href="https://www.mycomany.com">www.mycomany.com</a>

    Thursday, July 16, 2020 4:55 PM
  • User348806598 posted

    Hi,

    If you need to do this with backend code then you can simply use-

    Response.Redirect("~/")

    This will redirect to the root of the website, ideally its homepage. 

    Thursday, July 16, 2020 5:29 PM
  • User-939850651 posted

    Hi aspfun,

    This code you used:

    reponse.redirect("www.mycomany.com");

    Equivalent to:

    reponse.redirect("www.mycomany.com",true);

    It will call HttpResponse.End Method upon completion and throw a ThreadAbortException exception, which has an adverse effect on the performance of the web application.

    Therefore, I recommend that instead of this overload you use the HttpResponse.Redirect(String, Boolean) overload and pass false for the endResponse parameter, and then call the CompleteRequest method.

    For more details, you could refer to below link:

    https://docs.microsoft.com/en-us/dotnet/api/system.web.httpresponse.redirect?view=netframework-4.8

    Best regards,

    Xudong Peng

    Friday, July 17, 2020 2:26 AM
  • User546194788 posted

    Hi mgebhard, 

    Is it possible of using code behind form to do it?

    <a href="https://www.mycomany.com">www.mycomany.com</a>
    Friday, July 17, 2020 10:21 AM
  • User753101303 posted

    Hi,

    If you don't want to do anything a link is enough (and saves an extra redirection). It's also a bit unclear if you want this link to point to your site root or to a 3rd party site.

    Do you have some problem in doing what you want?

    Friday, July 17, 2020 10:52 AM
  • User475983607 posted

    Is it possible of using code behind form to do it?

    <a href="https://www.mycomany.com">www.mycomany.com</a>

    The <a> tag is written in the aspx page and displayed in the browser.  If the user clicks the link the browser goes to the href URL. 

    If you need to do redirect the browser from the code behind then use a Response.Redirect..  

    Since this is such a basic concept, I assume there is a problem you are trying to solve.  Can you explain what you are trying to do or why you wonder if there is a better way?  

    Friday, July 17, 2020 11:31 AM