简体   繁体   中英

javascript bundles in ASP.NET Core MVC not being served on IIS

I have developed a ASP.NET MVC Core app in Visual Studio which references bootstrap files in the wwwroot folder:

  /wwwroot/lib/bootstrap/dist/bootstrap.min.js

When I run the site in using IIS Express it return the file using this URL:

http://example.com/Identity/lib/bootstrap/dist/js/bootstrap.bundle.min.js

I am now deploying the site to IIS and this URL no longer works and returns a 404. I have configured the program to start with IIS Integration:

                     webBuilder
                        .UseContentRoot(Directory.GetCurrentDirectory())
                        .UseIISIntegration()
                        .UseStartup<Startup>();

What am I missing?

The "Identity" part of the URL comes from Identity Server 4, so it could be that the bootstrap.bundle.min.js file is come from this package.

Update your asset files as shown below and publish the app to the server:

<link href="~/lib/bootstrap/dist/bootstrap.min.js" >

change to

<link href="./lib/bootstrap/dist/bootstrap.min.js" >


Update: If some of the files cannot be published to the server, check this:

Select the file(s) that is not published to server and go to properties (click F4) of the file under properties, check the properties set for it:

Build Action: Content

Copy to Output Directory: Do not copy then publish it

Hope this helps.

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