发布我的webapi项目aspnet web api angularjs
我想将我的项目发布到IIS中的一个文件夹中,但是按照路由设置的方式,我得到了一个看起来像内部循环的东西,而没有找到路径 我已经在一个文件夹中发布了该项目发布我的webapi项目aspnet web api angularjs,angularjs,iis,asp.net-web-api,Angularjs,Iis,Asp.net Web Api,我想将我的项目发布到IIS中的一个文件夹中,但是按照路由设置的方式,我得到了一个看起来像内部循环的东西,而没有找到路径 我已经在一个文件夹中发布了该项目 angular.module("common.services", ["ngResource"]) .constant("appSettings", { //serverPath: "http://localhost:53967/" //name of the computer and folder to which the
angular.module("common.services", ["ngResource"])
.constant("appSettings",
{
//serverPath: "http://localhost:53967/"
//name of the computer and folder to which the project was published
serverPath:"http://ct-dx-ariang/AspNetWebApi/"
});
并进行如下的资源设置
angular.module("common.services").factory("productResource", ["$resource", "appSettings", productResource])
function productResource($resource, appSettings) {
//return $resource(appSettings.serverPath + "/api/products/:search");
return $resource(appSettings.serverPath + "/api/products/:id"
这是我的路线
$urlRouterProvider.otherwise("/");//default url
$stateProvider.state("home", {
url: "/",
templateUrl: "/templates/welcomeView.html"
}).state("productList", {
url: "/products",
templateUrl: "/templates/productListView.html",
controller: "ProductListController"
}).
如何修改此示例项目,使其在IIS上的已发布文件夹中运行,而不是在visual studio上的localhost中运行
这是我的路线
$urlRouterProvider.otherwise("/");//default url
$stateProvider.state("home", {
url: "/",
templateUrl: "/templates/welcomeView.html"
}).state("productList", {
url: "/products",
templateUrl: "/templates/productListView.html",
controller: "ProductListController"
}).
相当硬的编码。确保在所有模板中使用相同的常量
templateUrl: appSettings.serverPath + "/templates/welcomeView.html"
路径开头的斜线使该路径相对于站点的根。因此,在你的情况下:
templateUrl: "/templates/productListView.html"
将始终参考http://myhostname/templates/productListView.html
,无论您的站点位于哪个子路径
删除第一个斜杠可能会解决您的问题:
templateUrl: "templates/productListView.html"
同时查看您的
$resource
配置:
return $resource(appSettings.serverPath + "/api/products/:id"
和您的AppSettings
常量:
serverPath:"http://ct-dx-ariang/AspNetWebApi/"
在我看来,您正在向$resource
路径添加两个连续的斜杠。结果路径将为:http://ct-dx-ariang/AspNetWebApi//api/products/:id