简体   繁体   English

AngularJS页面刷新仅中断了应用程序中的一页

[英]Angularjs page refresh broken for only one page in app

I'm getting the Agularjs refresh returns 404 bug that has been well documented over the past few years, but I'm experiencing this issue on only one page in my app. 我正在获取Agularjs刷新返回的404错误,该错误已在过去几年中得到了很好的记录,但是我在应用程序的仅一页上遇到了此问题。 I have several pages that all resolve to their pages on refresh except for my user info page. 除了用户信息页面外,我还有几个页面都可以刷新为它们的页面。 Here is the routing code I have for it. 这是我的路由代码。 I have included the route for my dashboard page (which works) as well. 我也为我的仪表板页面添加了路由(也可以)。

$locationProvider.html5Mode(true);

    $stateProvider.
        state("home", {
            url: "/dashboard",
            controller: "dashboardController as vm",
            templateUrl: 'app/dashboard/view.html',
            resolve: {
                user: ['oauth',
                    function (oauth) {
                        return oauth.getOrLoadUser();
                    }]
            }
        }).
        state("updateInfo", {
            url: "/updateInfo",
            controller: "updateInfoController as vm",
            templateUrl: 'app/account/updateInfo.html',
            resolve: {
                user: ['oauth',
                    function (oauth) {
                        return oauth.getOrLoadUser();
                    }]
            }
        }).

As you can see I'm setting Html5Mode on for my locationProvider, and the route is identical to my other routes. 如您所见,我为我的locationProvider设置了Html5Mode,并且该路由与我的其他路由相同。 Any help would be much appreciated. 任何帮助将非常感激。

Update Here is what my routeConfig looks like. 更新这是我的routeConfig的外观。

public class RouteConfig
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        Dictionary<string, string> handleInHome = new Dictionary<string, string>();
        handleInHome.Add("login", "login/{*catchall}");
        handleInHome.Add("dashboard", "dashboard/{*catchall}");            
        handleInHome.Add("aboutus", "aboutus/{*catchall}");
        handleInHome.Add("requests", "requests/{*catchall}");
        handleInHome.Add("faq", "faq/{*catchall}");      

        foreach (var key in handleInHome.Keys)
        {
            routes.MapRoute(
               name: key,
               url: handleInHome[key],
               defaults: new { controller = "Home", action = "Index" }
           );
        }           


        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );
    }
}

I tried adding a catch all for the accounts folder, but I didn't make any difference. 我尝试为accounts文件夹添加一个catch all,但是没有任何区别。 handleInHome.Add("account", "account/{*catchall}"); handleInHome.Add(“ account”,“ account / {* catchall}”);

看起来您需要在后端处理/updateInfo路由,以确保为该路由提供Angular应用程序。

handleInHome.Add("updateInfo", "updateInfo/{*catchall}");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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