小编Ja9*_*35h的帖子

IIS Express中的ASP.NET核心虚拟目录

我使用VS2015在一个解决方案下创建了两个aspnet核心web和api项目

src
|
|-app.web
|  |-localhost:29999/
|  |-startup.cs 
|  
|-app.api
   |-localhost:29999/api/
   |-startup.cs (app.Map("/api", api => { /*configs and route*/ });)
Run Code Online (Sandbox Code Playgroud)

和修改后的.vs\config\applicationhost.config文件如下所示使用虚拟目录

<site name="ThreeCON.Web" id="2">
    <application path="/" applicationPool="Clr4IntegratedAppPool">
      <virtualDirectory path="/" physicalPath="C:\proj\src\app.web\wwwroot" />
      <virtualDirectory path="/api" physicalPath="C:\proj\src\app.api\wwwroot" />
    </application>
    <bindings>
      <binding protocol="http" bindingInformation="*:29999:localhost" />
    </bindings>
</site>
Run Code Online (Sandbox Code Playgroud)

当我尝试localhost:29999/api 在调试时访问url ,我收到404 not found错误(哪里localhost:29999/工作正常)

但是,当我通过在IIS中创建虚拟目录将其部署到开发服务器时,它的工作正常.那么我该如何解决这个问题才能使用IIS Express

debugging web-config iis-express visual-studio-2015 asp.net-core

7
推荐指数
1
解决办法
2099
查看次数

Angularjs动态添加控制器

看起来这几个问题已经问了好几次,但没有正确答案.

我的情况:我正在使用ajax(不使用angular routing temple因为某种原因)将一个模板(带有html和脚本)init加载到div.

index.html(主要)

<!DOCTYPE html>
<html ng-app="app" ng-controller="AppCtrl">
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Web</title>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.min.js"></script>
    </head>
    <body>
        <div class="container body-content">
            <div class="dynamic-content" >
                <!-- Loading content Here -->
            </div>
            <button ng-click="loadTemplate()">Load Template</button>
        </div>

        <script>
            angular.module('app', [])
            .controller('AppCtrl', function ($scope) {
                $scope.someData = {};
                $scope.loadTemplate = function() {
                    ....
                    //AJAX to get the templet.html
                    //and load it into .dynamic-content
                    //then applying scope();                  
                }
            });
        </script>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

template.html(模板)

<div ng-controller="TempCtrl">
    <h2>About</h2>
    <h3>{{total}}</h3>
    <p>Testing the …
Run Code Online (Sandbox Code Playgroud)

html javascript angularjs single-page-application

2
推荐指数
1
解决办法
9543
查看次数