【问题标题】:A web page is slowing down your browser, it is waiting for csi.gstatic.com一个网页正在减慢您的浏览器,它正在等待 csi.gstatic.com
【发布时间】:2018-08-02 13:16:07
【问题描述】:

我已经在 .net 2017 c# 上编写了 Web 应用程序,我必须将我的 URL 更改为更简单才能摆脱?或 = 来自 URL,我也在我的网站上使用 Google Map。当我单击将被重定向并更改为其他链接的记录时,出现此错误。

原始网址是:mydomain.com/Doctor?id=XX
我将其转换为:mydomain.com/Doctor/XX

我通过将 RegisterRoutes 上的新 MapRoute 定义为: RouteCofig.cs:

public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.MapRoute(
               "Blog",                                           // Route name
               "Doctor/{id}",                                   // URL with parameters
               new { controller = "Home", action = "PersianDR", id = UrlParameter.Optional }  // Parameter defaults
           );
            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
           );
        }

我还使用了 angularjs: 角模块:

var app = angular.module('MyApp', ['ngRoute', 'uiGmapgoogle-maps', 'nemLogging', 'ngSanitize']);
app.config(['$routeProvider', '$locationProvider', function ($routeprovider, $locationProvider) {
    $routeprovider.
        when('/Home/PersianDR/:id', {
            templateurl: '/Views/Home/PersianDR.cshtml',
            controller: 'AngularCtrl_ShowDr'
        })
        .
        when('Doctor/:id', {
            redirectto: '/Home/PersianDR/:id'
        })
        .
        otherwise({
             redirectto: '/'
        })
        ;
    //$locationProvider.html5Mode(true);
    $locationProvider.html5Mode({
        enabled: true,
        rewriteLinks: false
    });
}]);

角度控制器:

app.controller("AngularCtrl_ShowDr", function ($scope, $location, angularService_ShowDr, $route, $routeParams, $http, $sce) {
    var docId = $("#myId").val();
 
    $location.path();
    $location.url('Doctor/' + docId).replace();
  
    GetDoctorByID();
    GetGeoCoordinates();
    maps();
});

这个问题自从我更改 URL 后就开始了。

【问题讨论】:

    标签: angularjs asp.net-mvc google-maps asp.net-mvc-4


    【解决方案1】:

    我终于找到了一个有趣的答案。 当我在使用 google map api 时想要重定向并使我的 url 简单时出现冲突,这是因为 gmap 需要绝对路径或 url 而我想简单而优雅地更改我的 url。

    为了消除等待加载 csi.gstatic.com 的问题,我所做的是使用局部视图。

    我完全将我的 ui-gmap-google-map 带入局部视图并从原始视图中调用它。

    在原始page.cshtml中:

     @Html.Partial("_MapDoctor")
    

    在局部视图中,_MapDoctor.cshtml:

    <div ng-controller="AngularCtrl_MapDr">
        <input type="hidden" id="myId2" value="@ViewBag.id" />
        <ui-gmap-google-map center='mapsdrsec.center' zoom='mapsdrsec.zoom' options='mapsdrsec.options'>
            <ui-gmap-layer type="TrafficLayer" show="mapsdrsec.showTraficLayer"></ui-gmap-layer>
            <ui-gmap-markers models="markers" idkey="markers.id" coords="'coords'">
    
            </ui-gmap-markers>
        </ui-gmap-google-map>
    
    </div>
    

    我在 angularjs 中为局部视图编写了指定的控制器和服务。我从原始中删除了填充 $scope.map 并在部分视图控制器中写入(中心、缩放、选项、$scope.markers)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-03
      • 1970-01-01
      • 2014-01-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多