【发布时间】: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