| The author makes a report Presentation website where the reports are stored on the server in Excel format. He or she wants to download the Excel report by the login or authorized person. However, the file download path cannot be hidden, so page control is useless. Recently, when I was studying IIS, I suddenly became very open. First, edit or modify the Web. config of the website, and add or modify the red area. <! -- Authentication This section sets the applicationProgramAuthentication Policy. Possible modes are windows ", "Forms", "Passport", and "NONE" "None" does not perform authentication. "Windows" IIS performs Authentication Based on application settings (Basic, simple, or integrated windows ). Anonymous access must be disabled in IIS. "Forms" you provide users with a custom form (web page) for entering creden,, and then Verify their identity in your application. User creden are stored in cookies. "Passport" authentication is performed through Microsoft's centralized identity authentication service, It provides independent logon and core configuration file services for member sites. --> <Authentication mode = "forms"> <Forms name = ". aspxuserdemo "loginurl =" login. aspx "Protection =" all "timeout =" 60 "Path ="/"> <credentials passwordformat =" sha1 "/> </Forms> </Authentication> <! -- Authorization This section sets the application Authorization Policy. Allow or Deny Access From different users or roles Application resources. Wildcard: "*" indicates anyone ,"? "Anonymous (Unauthenticated) user. --> <Authorization> <Deny users = "? "/> <! -- <Allow users = "[comma-separated user list]" Roles = "[list of roles separated by commas]"/> <Deny users = "[comma-separated user list]" Roles = "[list of roles separated by commas]"/> --> </Authorization> Then write login. aspx For Login winners Formsauthentication. setauthcookie (UID, false ); Formsauthentication. redirectfromloginpage (UID, false ); Open IIS, find your website, right-click, select Properties,-> main directory-> Configuration Then, select "ing, Add example. Now, let's see what you can see when you access the xls file http: // localhost/SMS/1.xlsunder the main site? Yes, you need to log on. You can download this file only when you enter the logon information! Yes, that's simple. If role is added, more complex control can be performed. Welcome to the discussion (maximon@sina.com Wuxi state tax huichun) |