$ P $在asp.net被送达pvent一个文件(PDF) [英] Prevent a file (pdf) from being served in asp.net

查看:118
本文介绍了$ P $在asp.net被送达pvent一个文件(PDF)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个传统的Flash应用程序(以源无法访问),它完成时,它在一个新窗口自动打开PDF文件。

I've got a legacy flash app (no access to the source) that when it completes it opens a pdf in a new window automatically.

有一些方法,以prevent这个文件从开放这一个特定的位置(同样,记住我不能编辑闪光灯)

Is there some way to prevent this one file at this one specific location from opening (again, keeping in mind I cant edit the flash)

因此​​,打开 http://site.com/Files/Video/Completion.pdf 直接在浏览器,没有处理或任何改变。

So it opens to http://site.com/Files/Video/Completion.pdf directly in the browser, no handler or anything to change.

推荐答案

您可以删除该文件夹,将prevent文件被访问,除非他们是在一个特定的角色在一个web.config:

You can drop a web.config in that folder which will prevent the files from being accessed unless they are in a specific role:

<configuration>
    <system.web>
        <authorization>
           <allow roles="WHATEVER-ALLOWED-ROLES"/>
           <deny users="*"/>
        </authorization>
    </system.web>
</configuration>

如果您只想锁定特定文件,你可以换行&LT;的System.Web&GT; &LT;位置路径=文件路径-and名&GT;

If you only want to lock down that specific file you can wrap that <system.web> with <location path="filepath-and-name">

这可能会需要你到以下处理程序添加到您的根web.config中的处理程序一节中,因为通常IIS将成为该文件ASP.NET接触它之前。这将使PDF文件通过ASP.NET那么它可以处理角色的限制从上面:

This will likely require you to add the following handler to your root web.config in the "handlers" section, as usually IIS will serve up the file before ASP.NET touches it. This will make PDFs go through ASP.NET which can then handle the Role restrictions from above:

<add name="PDFHandler-Integrated" path="*.pdf" verb="GET" type="System.Web.StaticFileHandler" modules="ManagedPipelineHandler" requireAccess="Script" preCondition="integratedMode" />

这篇关于$ P $在asp.net被送达pvent一个文件(PDF)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆