Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 部署角度4 IIS错误“;403-禁止:访问被拒绝。”;_Angular_Iis_Angular Ui Router_Web Config_Webdeploy - Fatal编程技术网

Angular 部署角度4 IIS错误“;403-禁止:访问被拒绝。”;

Angular 部署角度4 IIS错误“;403-禁止:访问被拒绝。”;,angular,iis,angular-ui-router,web-config,webdeploy,Angular,Iis,Angular Ui Router,Web Config,Webdeploy,我试图在IIS服务器上部署Angular 4网站,但遇到此错误 “403-禁止:访问被拒绝。” 我使用的URL是,而“客户端”并不是我Angular项目中的实际组件,而是让我的登录页面知道在页面上显示哪些徽标和颜色。以下是我的app.routes.ts中的代码 const routes: Routes = [ { path: '', redirectTo: 'login', pathMatch: 'full' }, {

我试图在IIS服务器上部署Angular 4网站,但遇到此错误

“403-禁止:访问被拒绝。”

我使用的URL是,而“客户端”并不是我Angular项目中的实际组件,而是让我的登录页面知道在页面上显示哪些徽标和颜色。以下是我的app.routes.ts中的代码

const routes: Routes = [
    {
        path: '',
        redirectTo: 'login',
        pathMatch: 'full'
    },
    {
        path: 'login/:clientCode',
        component: LoginComponent
    },
...
以下是我的web.config,以备参考:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <modules>
      <remove name="UrlRoutingModule-4.0" />
    <add name="UrlRoutingModule-4.0" 
type="System.Web.Routing.UrlRoutingModule" preCondition="" />
</modules>
    <handlers>
      <remove name="UrlRoutingHandler"/>
    </handlers>
    <rewrite>
      <rules>
        <rule name="Angular" stopProcessing="true">
          <match url=".*" />
          <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          </conditions>
          <action type="Rewrite" url="/" />
        </rule>
      </rules>
    </rewrite>
     <staticContent>
    <remove fileExtension=".json" />
    <mimeMap fileExtension=".json" mimeType="application/json" />
  </staticContent>
       <defaultDocument>
           <files>
               <remove value="index.php" />
               <remove value="default.aspx" />
               <remove value="iisstart.htm" />
               <remove value="index.htm" />
               <remove value="Default.asp" />
               <remove value="Default.htm" />
            </files>
       </defaultDocument>
  </system.webServer>


谢谢你的帮助。

所以问题是当我构建我需要添加的应用程序时--base ref/我的域名/如下所示:

ng build -env=dev --base-href /LPPortal2/
此外,我还需要将重写更新为

<action type="Rewrite" url="/LPPortal2" />


这两件事修复了我的403错误。

所以问题是当我构建我的应用程序时,我需要添加--base ref/我的域名/如下所示:

ng build -env=dev --base-href /LPPortal2/
此外,我还需要将重写更新为

<action type="Rewrite" url="/LPPortal2" />


这两件事修复了我的403错误。

以管理员身份运行IDE以打开Angula文件夹,它将正常工作,您可以保存您的工作,因为我遇到了相同的问题并运行了Visual Studio代码(您可以使用任何您喜欢的IDE类型)管理员解决了问题。

以管理员身份运行IDE以打开Angula文件夹,它将工作,您可以保存您的工作,因为我遇到了相同的问题,并且在管理员解决问题时运行Visual Studio代码(您可以使用您喜爱的任何类型的IDE)