locked
MVC Controller to redirect, without changing URL RRS feed

  • Question

  • User-1706989909 posted

    Hello All,

    I have to navigate to another URL from my application, https://myapp.com/Help, But it should redirect to http://google.com but exisiting URL shouldn't  be changed. 
    This  redirection is happening from mvc-5 Controller action.

    If anyone knows kindly help me.

    Regards

    Shil

    Monday, November 5, 2018 12:39 PM

All replies

  • User-821857111 posted

    I have to navigate to another URL from my application, https://myapp.com/Help, But it should redirect to http://google.com but exisiting URL shouldn't  be changed. 
    Do you want to show the content of an external site? If so, you should look as iframes.

    Monday, November 5, 2018 2:09 PM
  • User-474980206 posted
    A redirect is a command sent to the browser to load a particular page. The browser controls the url in nav.

    A url rewrite is when your site internally changes the url without telling the browser. The only way to use rewrite with an external site is to proxy it. That is your webserver call the external site and returns content. You will need to parse the external html for links, and fix up to point to your site.
    Monday, November 5, 2018 3:04 PM
  • User1080785583 posted

    I would look into attribute routing. Fairly straightforward.

    https://blogs.msdn.microsoft.com/webdev/2013/10/17/attribute-routing-in-asp-net-mvc-5/

    Monday, November 5, 2018 4:56 PM
  • User1520731567 posted

    Hi shilpa.gururao,

    In MVC,you would like to navigate to another URL,without changing URL(it means not changing controller and action).

    I'm not sure if i get your point.

    Why not use return Redirect();

    For example:

         public ActionResult Index()
            {
    
                return Redirect("https://www.google.com/");
           
            }

    Best Regards.

    Yuki Tao

    Tuesday, November 6, 2018 6:37 AM