简体   繁体   English

与控制器操作同名的虚拟目录

[英]virtual directory with same name as controller action

I have a Asp.Net MVC controller with the url localhost/desktop . 我有一个URL为localhost / desktop的Asp.Net MVC控制器。 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. 我现在想将虚拟目录添加到IIS,该目录也托管在返回静态文件的localhost / desktop上。 So localhost/desktop should route to the asp controller action and anything in the desktop "directory" should just return static files. 因此, localhost / desktop应该路由到asp控制器操作,并且桌面“目录”中的任何内容都应该返回静态文件。 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. 据我所知,具有共享文件夹等的iis的全部目的是将文件直接提供给浏览器。 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 . MVC还是我应该说.Net将帮助您提供有关文件夹内容的信息。 You can of course enable folder browsing on iis but I can't imagine anyone would recommend that. 您当然可以在iis上启用文件夹浏览,但是我无法想象有人会建议这样做。 The .net library makes light work of building up a virtual view of a folder. .net库简化了构建文件夹的虚拟视图的工作。 How you display this on the front end is up to you but Google will be your friend here. 您如何在前端显示此内容取决于您,但Google会成为您的朋友。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 403.14-当IIS中的控制器名称和控制器目录名称相同时,禁止使用 - 403.14 - Forbidden when controller name and controller directory name is same in IIS 将控制器操作呈现为字符串(使用虚拟路径,无操作/控制器名称)ASP.NET MVC 3 - Render Controller Action To String (Using Virtual Path, No action/controller name) ASP.NET MVC 3 控制器的动作在具有相同名称的基类的动作之间是不明确的。 - The controller's action is ambiguous between the action of the baseclass with same name. 在同一个Controller中具有相同Action名称的GET和POST方法 - GET and POST methods with the same Action name in the same Controller 获取虚拟目录的名称? - Get name of virtual directory? MVC路由不适用于虚拟目录上的非默认/根操作控制器 - MVC routing does not work for non-default/root action controller on virtual directory 与操作控制器同名的RouteValue字符串错误 - Error with a RouteValue string that has the same name as an Action Controller 如何在控制器中使用相同名称和签名覆盖操作方法? - how to override a action method in the controller with same name and signature.? 当两个控制器的动作名称相同时,从另一个控制器重定向到该控制器的动作 - Redirect to a controller's action from another controller while action name is same in both controllers @ Url.Action(“ Action”,“ Controller”)调用具有相同名称的post和get方法 - @Url.Action(“Action”,“Controller”) calls both post and get method with same name
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM