我已经在.net 2017 c#上写了网络应用程序,我不得不将我的网址更改为更简单以便摆脱?或=来自网址,我也在我的网站上使用谷歌地图。当我点击将被重定向并更改为其他链接的记录时,我收到此错误。 原始网址是: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();
});
自从我更改了网址以来,这个问题已经开始了。
感谢您提前或任何帮助。
答案 0 :(得分:0)
我终于找到了一个有趣的答案。 当我想使用谷歌地图apis时,我想重定向并使我的网址简单,这是一个冲突,这是因为gmap需要绝对路径或网址,而我想改变我的网址简单而优雅。
我在删除等待加载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,并在部分视图控制器中写入(center,zoom,options,$ scope.markers)。