How to serve static files from mvc without using content folder?

I want to have a folder that allows regular access, such as the \ content folder, except that it contains the ClickOnce application. It seems I cannot achieve this with Mvc, but I would like this folder to be accessible without Mvc, considering it as a controller action.

I tried using routes.Ignore(theUrl) , but this did not seem to have an effect.

+4
source share
2 answers

There are two ways to do this. The first is where you are right now to satisfy its routing. To ignore the intended route, you should use the following:

 routes.IgnoreRoute("...") 

However, this may not be the right security approach. I would recommend that you define an explicit action to load your click-once exe. See this q / a for an example of using the FileContentResult class.

The reason for this is that you can control security for this file without opening access levels to other directories.

Change If this is for the entire catalog, you can still follow the same approach.

+2
source

Configure the folder as a virtual folder on the IIS website. then you can set the url in the code to indicate the machine serving the request and the virtual folder on the web server.

+1
source

Source: https://habr.com/ru/post/1392711/


All Articles