【问题标题】:Why my angularjs URL route is different?为什么我的 angularjs URL 路由不同?
【发布时间】:2015-07-06 23:44:38
【问题描述】:

我的查询与 Rewrite AngularJS URL 完全相同,但我使用 IIS 作为我的 Web 服务器。

如何修复网址?目前我的网址看起来像

http://example.com/app#/ 

需要像这样改变

http://example.com/app/#/

【问题讨论】:

    标签: angularjs angular-ui-router


    【解决方案1】:

    如果我们使用 ASP.NET MVC 运行时来触发 HomeController 上的 Index 操作以充当“index.html”(返回视图 index.cshtml) - 我们只需将这些行添加到其中:

    public ActionResult Index()
    {
        var root = VirtualPathUtility.ToAbsolute("~/");
        var applicationPath = Request.ApplicationPath;
        var path = Request.Path;
    
        var hasTraillingSlash = 
              root.Equals(applicationPath, StringComparison.InvariantCultureIgnoreCase)
           || !applicationPath.Equals(path, StringComparison.InvariantCultureIgnoreCase);
    
        if (!hasTraillingSlash)
        {
            return Redirect(root + "#");
        }
    
        return View();
    }
    

    查看Browser address will not be displayed correctly in ui-route

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-03-06
      • 2022-06-25
      • 1970-01-01
      • 2016-10-17
      • 1970-01-01
      • 2021-02-28
      • 1970-01-01
      相关资源
      最近更新 更多