开发者

How to force ASP.NET to ignore a virtual subdirectory completely

I 开发者_JAVA百科have an ASP.NET MVC 3 application, that resides in lets say localhost/myapp under IIS.

There is a virtual directory (not application) localhost/myapp/upload under that application in IIS (version 7+) that is mapped to a network share.

I want ASP.NET to ignore requests to files under that directory, and let IIS handle the request on its own.

I tried things like adding routes.IgnoreRoute("upload/{*pathInfo}") to global.asax.cs but still no luck.

Getting ASP.NET errors like failed to start monitoring changes to '\\server\share\myupload\web.config' when i try to access a static file e.g. a jpeg under that directory.

There is no web.config file under that upload directory. It is not an ASP.NET application. And i don't want to grant access to network service, or ASP.NET user to just let it check that no such file exists there. If i do, someone would upload an .aspx file there and execute whatever code they like in my server.

Any ideas?


The best solution for this case would probably be to disable directory listing for this directory like in this tutorial :

http://technet.microsoft.com/en-us/library/cc731109(WS.10).aspx

And for download links, you should create a permalink database and store them in database. So if you have file at www.mysite.com/myapp/upload/file1.doc , the URL that user will see would be www.mysite.com/myapp/ControllerThatHandlesRedirect/{some guid }. All the links would be stored in database and would be taken from the database according to specific guid. So the user will not see the real URL only a GUID . The controller would select URL from database based on the permalink and redirect user to that file .

Hope that helps you

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜