Permissions Control (ASP.NET)

zhaozj2021-02-16  50

The author makes a report show that the report is stored in the server, and people who wish to log in or those who have permission can download the Excel report. But the path downloaded by the file cannot be hidden, so page control is not used. When I study IIS in recent days, I suddenly suddenly became open.

First edit or modify the website's web.config, join or modify the red area

This section sets the application's authentication policy. Possible mode is "windows",

"Forms", "Passport" and "NONE"

"None" does not perform authentication.

"Windows" IIS executes authentication according to the application settings

(Basic, brief or integrated Windows). Anonymous access must be disabled in IIS.

"Forms" you provide users with a custom form (web page) for entering credentials, then

Verify their identity in your app. User credentials are stored in cookies.

"Passport" authentication is performed by Microsoft's centralized authentication service,

It provides a separate login and core configuration file service for the member site.

->

This section sets the authorization policy for the application. Can be allowed or rejected different users or roles to access

Application resources. Wildcard: "*" means anyone, "?" Indicates anonymous

(Without authentication) users.

->

Roles = "[comma-separated list]" />

Roles = "[comma-separated list]" />

->

Then write login.aspx

Join for successful login

Formsauthentication.SetAuthCookie (UID, FALSE);

Formsauthentication.RedirectFromLoginPage (UID, FALSE);

Open IIS, find your website, right click, select the attribute, - "Main Directory -" Configuration

Then select it in "Mapping",

Add as shown above.

Ok, I'm big, I will now visit an XLS document under the main station http://localhost/sms/1.xls, what?

Oh, yes, you need to log in. When you enter login information and log in to you can download this file!

Yes, it is as simple, if you add ROLE, more complex control can be performed.

Welcome to exchange (Maximon@sina.com Wuxi national tax 瞿 惠 春)

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

New Post(0)