简体   繁体   中英

ASP.NET MVC Redirect to Home Page from Error Page

I am trying to redirect to home page on click of banner. But it is not working as expected. Error occured on 'Work' controller. Error Page showed up as expected on exception, but on click of banner it redirects to

http://127.0.0.1:81/Error?aspxerrorpath=/Work/Home

Javascript used:

function redirectToHome() {
        var page = 'Home';
        window.location = page;
    }

It works from any other page , but not from error page.

Try this

var url = '@Url.Action("Home", "Login")';
            window.location.href = url;

Try using this,

function redirectToHome() {
        var page = '/Home';
      window.location.href=page
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM