简体   繁体   English

使用dotnet和angular2

[英]Working with dotnet and angular2

I have recently integrated a boostrap admin template (based on Angular2) in an asp project (here is the repo ) 我最近将一个boostrap admin模板(基于Angular2)集成到一个asp项目(这是repo )中

The thing is: when I am running tsc , all files compile well, but if I change html files, if the web browser (let say firefox) opened the project previously, the page never change, but if I open a new web browser (let say chrome) I can see the change. 关键是:当我运行tsc ,所有文件都可以很好地编译,但是如果更改html文件,则如果Web浏览器(比如说firefox)以前打开了该项目,则页面永远不会改变,但是如果我打开一个新的Web浏览器(假设是chrome)我可以看到更改。 Now, if I change an html again, neither one can detect new changes in html files. 现在,如果我再次更改html ,则没人能检测到html文件中的新更改。

I think it is dotnet configuration, because I used the bootstrap angular template which is set up with npm lite server, and it has not any problems (I mean: change .ts files, .html files and it refresh always well) 我认为这是dotnet配置,因为我使用了由npm lite服务器设置的bootstrap角度模板,并且没有任何问题(我的意思是:更改.ts文件, .html文件,并且刷新总是很好)

To reproduce the problem, these are the steps: 要重现此问题,请执行以下步骤:

  1. npm install npm安装
  2. dotnet restore 点网还原
  3. dotnet run 网络运行
  4. go to /pages/login <- It displays everything ok 转到/ pages / login <-它显示一切正常
  5. edit login.component.ts : template: <h1> Hello!</h1> 编辑login.component.tstemplate: <h1> Hello!</h1>
  6. go to /pages/login <- It keeps showing the login form 转到/ pages / login <-它一直显示登录表单
  7. go to /pages/login (google-chrome) <- It shows the change 转到/ pages / login(google-chrome)<-显示更改
  8. edit login.component.ts : template: <h1> Hello World!</h1> 编辑login.component.tstemplate: <h1> Hello World!</h1>
  9. go to /pages/login (google-chrome) <- It only shows Hello! 转到/ pages / login(google-chrome)<-仅显示Hello!

The asp app were caching the pages, so I changed the web.config asp应用程序正在缓存页面,因此我更改了web.config

 <system.webServer>
    <httpProtocol>
        <customHeaders>
            <add name="Cache-Control" value="no-cache, no-store" />
            <add name="Pragma" value="no-cache" />
            <add name="Expires" value="-1" />
        </customHeaders>
    </httpProtocol>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
    </handlers>
    <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
  </system.webServer>
</configuration>

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

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