Control image does not let an anonymous download method

zhaozj2021-02-16  47

There is more pictures, and the name of the file is rule. In order to prevent some people from being downloaded, the picture needs to be controlled, and after n-test, finally finally get it. Methods as below:

First, create a picture file map

------- 1, start IIS, right-click the site you want to set

------- 2, select "Virtual Directory" == "Configuration ==" Add

------- 3, entered in "Executable File":

C: /Winnt/Microsoft.Net/framework/v1.1.4322/ASPNET_ISAPI.DLL ------- 4, the extension is entered: .gif == determined

------ 5, if you add multiple, you can repeat steps 3, 4

Second, set the authentication in the web.config file to Forms verification, but to allow anonymous access

Third, in the file of the picture file, then the web.config file is new, the content is as follows:

But this will have a problem, that is, you must see the picture through verification, so don't work, you should write a basics, from system.web.ui.page, rewrite

Override Protected Void OnNit (Eventargs E) Method:

IF (! this.user.Identity.IstiThenticated) Formsauthentication.RedirectFromLoginPage ("Guest", false); four, modify the basics of WebForm

This is equivalent to setting an "anonymous" authentication user, and the picture can be displayed.

Of course, this is a stupid method, I hope that it will be better.

转载请注明原文地址:https://www.9cbs.com/read-19264.html

New Post(0)