Developing ASP.NET MVC Web Applications — Question 153

You are developing an ASP.NET Core MVC web application that provides assets to external websites including images, JavaScript scripts and text files.
The external websites must be able to make full use of assets provided to them by the web application, including JavaScript asynchronous HTTP requests.
Pages that refer to the images and text files do not load. External websites are unable to use assets.
You need to resolve the issues.
What should you do?

Answer options

Correct answer: B

Explanation

The correct answer is B because configuring StaticFiles in the startup Configure method allows the application to serve static files directly from the specified folder, thus enabling external websites to access them. Option A is incorrect as it requires additional overhead of creating a controller. Option C is also not suitable since DirectoryBrowser is not needed for serving static files. Option D does not address the issue of serving files over HTTP.