.net core service && angular项目 iis发布

项目结构

.net core 后端服务站点
angular 前端页面站点

项目模板来自于abp或者52abp

.net core 后端服务站点发布到IIS

发布报错

.Net Core使用IIS部署出现502Error 502.5 - Process Failure

在项目目录运行命令行,执行

dotnet XXXWeb.dll   --XXXWeb.dll是启动项   

如果.net core版本不对,则会提示需要安装某版本的.net core
12
完成安装即可
参考资料

appsettings.json

在appsettings.json中设置客户端地址ClientRootAddress

"App": {
  "ServerRootAddress": "http://localhost:3521/",
  "ClientRootAddress": "http://localhost:4201/",
  "CorsOrigins": "*"
}

注意

发布前记住关闭swagger ui等开发工具

angular前端页面站点

在angular项目文件中执行

ng build --prod --aot

解决相关报错,生成dist文件夹,包括

bundle
XXX  --XXX是你的项目名

在IIS中,新建站点,将XXX文件夹作为根目录
在XXX文件夹中新建文件web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="AngularJS" 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>
  </system.webServer>
</configuration>

在/XXX/assets/appconfig.prod.json中设置service地址remoteServiceBaseUrl

{
  "remoteServiceBaseUrl": "http://localhost:3521"
}

参考资料

https://blog.csdn.net/qq_32688731/article/details/80996669
https://angular.io/guide/deployment#server-configuration

猜你喜欢

转载自www.cnblogs.com/Lulus/p/10552048.html
今日推荐