简体   繁体   中英

virtual directory with same name as controller action

I have a Asp.Net MVC controller with the url localhost/desktop . This works as it should. I now would like to add a virtual direcotry to IIS also hosted at localhost/desktop which returns static files. So localhost/desktop should route to the asp controller action and anything in the desktop "directory" should just return static files. How would I go about this?

As far as I am aware the whole point of iis having shared folders etc is to serve files directly to the browser. You don't need to go through a controller. What you do want to do is give the user some way to browse the content of the folder providing a link to the required content. The browser can then display the file if it supports rendering or download if it does not.

MVC or should I say .Net will help you provide the info on the folder contents . You can of course enable folder browsing on iis but I can't imagine anyone would recommend that. The .net library makes light work of building up a virtual view of a folder. How you display this on the front end is up to you but Google will be your friend here.

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