简体   繁体   中英

Working with dotnet and angular2

I have recently integrated a boostrap admin template (based on Angular2) in an asp project (here is the 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. Now, if I change an html again, neither one can detect new changes in html files.

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)

To reproduce the problem, these are the steps:

  1. npm install
  2. dotnet restore
  3. dotnet run
  4. go to /pages/login <- It displays everything ok
  5. edit login.component.ts : template: <h1> Hello!</h1>
  6. go to /pages/login <- It keeps showing the login form
  7. go to /pages/login (google-chrome) <- It shows the change
  8. edit login.component.ts : template: <h1> Hello World!</h1>
  9. go to /pages/login (google-chrome) <- It only shows Hello!

The asp app were caching the pages, so I changed the 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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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