我在项目中使用Asp.Net和Angular JS。我想创建我的路线,如下所示。
必需的网址格式:http://localhost:9196/hotelname-cityname
例如:http://localhost:9196/magnolia-bengaluru
我想在我的角应用中访问这些酒店名称和城市名称。
我开始知道,我需要重写iis规则以及角度应用程序路由更改。请帮我怎么做?
注意:我在项目中没有使用MVC控制器。
var app = angular.module("rezeapp", ["ngRoute"]);
app.config(function ($routeProvider, $locationProvider) {
$routeProvider
.when("/:propertyName-:cityName", {
templateUrl: "reze_modules/inventory/inventorytemplate.html",
controller: "inventorycontroller",
resolve: {
propertyInventory: function ($route) {
console.log($route.current.propertyName);
console.log($route.current.cityName);
}
}
})
.when("/property/cart", {
templateUrl: "reze_modules/inventory/inventorytemplate.html",
controller: "inventorycontroller",
resolve: {
checkUrl: function ($route) {
console.log($route.url());
}
}
}).otherwise({ redirectTo: "/property/cart" });
$locationProvider.html5Mode(true);
});
Web.Config更改:
<rewrite>
<rules>
<rule name="RezEPropertyUrl" stopProcessing="true">
<match url="^/*." />
<action type="Redirect" url="/{R:2}-{R:1}" redirectType="Found" />
</rule>
<rule name="RezEDefaultPage" stopProcessing="true">
<match url="^Property/Cart" />
<action type="Rewrite" url="/home.html" />
</rule>
</rules>
</rewrite>