[英]HttpContext.Current.Request with Angular ui-router
Using Asp.Net I am capturing the request of an AngularJS
Route as it loads. 使用Asp.Net,我正在捕获AngularJS
路由的请求。 The route is /FST/#/quickstart
. 路由是/FST/#/quickstart
。 I am trying to capture that route with: 我正在尝试通过以下方式捕获该路线:
var currentUrl = HttpContext.Current.Request.RawUrl;
however, the RawUrl
doesn't contain the #/quickstart
subpart. 但是, RawUrl
不包含#/quickstart
子部分。 There doesn't seem to be any thing in the Request than can tell me the full URL. 要求中似乎没有什么可以告诉我完整的URL。 How can I get the target URL? 如何获得目标URL?
You Can use a $http
interceptor to add the current route as a header to your web api request 您可以使用$http
拦截器将当前路由添加为Web API请求的标头
$httpProvider.interceptors.push(['$q','$location' function($q, $location) {
return {
'request': function(config) {
config.headers.ClientSideUrl = $location.path();
return config || $q.when(config);
},
'requestError': function(rejection) {
return $q.reject(rejection);
},
'response': function(response) {
return response || $q.when(response);
},
'responseError': function(rejection) {
return $q.reject(rejection);
}
};
}]);
And then access the header server side: 然后访问标头服务器端:
HttpContext.Current.Request.Headers.GetValues("ClientSideUrl").FirstOrDefault();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.