简体   繁体   English

IIS7上的Angular 7应用程序中的500(URL重写模块错误。)

[英]500 (URL Rewrite Module Error.) in Angular 7 app on IIS7

I have an Angular 7 application I am hosting on IIS 7, which should be accessible at https://example.com/fitcbooks/web . 我有一个我在IIS 7上托管的Angular 7应用程序,可以通过https://example.com/fitcbooks/web访问。 This was working, then suddenly stopped - for reason I can't seem to understand. 这工作,然后突然停止 - 因为我似乎无法理解。 The URL Rewrite on the server seems to be working (used to redirect other sites on same server) but it just breaks down for this particular app. 服务器上的URL Rewrite似乎正在工作(用于重定向同一服务器上的其他站点),但它只是为这个特定的应用程序分解。

I HAVE ALREADY INSTALLED URL REWRITE MODULE 2 for IIS7. 我已经为IIS7安装了URL REWRITE MODULE 2。 I also built the angular application using --base-ref and already used the web.config code as shown below. 我还使用--base-ref构建了角度应用程序,并且已经使用了web.config代码,如下所示。 I have also built a local version of the app and it works perfectly on my macbook running AMPPS, eliminating any issues in the app itself. 我还构建了一个本地版本的应用程序,它在运行AMPPS的macbook上完美运行,消除了应用程序本身的任何问题。 This looks like a server problem. 这看起来像服务器问题。

web.config: web.config中:

<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Angular Routes" 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="/fitcbooks/web/index.html" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

index.html: index.html的:

<base href="/fitcbooks/web/">

Currently the app's preloader just loads forever. 目前应用程序的预加载器只是永远加载。 The console shows several 500 (URL Rewrite Module Error.) errors. 控制台显示几个500(URL重写模块错误。)错误。 Please kindly help. 请帮忙。

Finally solved this! 终于解决了这个!

The problem was the automatic encryption of files zip-compressed on mac. 问题是在mac上压缩压缩文件的自动加密。 I just switched from Windows to Mac because of iOS development last week, so I'm new to this. 由于上周的iOS开发,我刚从Windows切换到Mac,所以我是新手。

I was able to figure this out by reading the details of the 500 HTTP error using Failed Request Tracing Rules in IIS (thanks to @LexLi for the Fiddler tip). 我能够通过使用IIS中的失败请求跟踪规则读取500 HTTP错误的详细信息来解决这个问题(感谢@LexLi提供的Fiddler提示)。 I observed the logs and discovered that the specific Error was 500:50 . 我观察了日志,发现特定的错误是500:50 Also found ErrorCode Access is denied. (0x80070005) 还发现ErrorCode Access is denied. (0x80070005) ErrorCode Access is denied. (0x80070005) , which made me realize it had something to do with access to the file. ErrorCode Access is denied. (0x80070005) ,这让我意识到它与访问该文件有关。 After some online digging, I found this forum post ( https://forums.iis.net/t/1164360.aspx ), installed Process Monitor and saw that clearly, the Server couldn't access the app's files. 经过一些在线挖掘后,我发现这个论坛帖子( https://forums.iis.net/t/1164360.aspx ),安装了Process Monitor并清楚地看到,服务器无法访问应用程序的文件。

The folders in the app had green labels, so I realized they were encrypted. 应用程序中的文件夹有绿色标签,所以我意识到它们是加密的。 I re-uploaded the files without encrypting and that was it - the app was working! 我重新上传文件而没有加密,就是这样 - 应用程序正在运行! So I learned the hard way that files compressed on a mac might give you problems on windows. 所以我学到了很难在Mac上压缩的文件可能会给你带来windows问题。

Just putting this out here in case it helps someone else. 只是把它放在这里,以防它帮助其他人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM