简体   繁体   English

允许任何人查看ASP.NET MVC中的网页

[英]Allowing anyone to View a webpage in ASP.NET MVC

I have a website designed using ASP.NET MVC4 which has a specific Controller 'ProductionLogs' which will display the top 25 logs from the Production Server on typing the URL https://(myapp.com)/ProductionLogs/GetTop25Logs . 我有一个使用ASP.NET MVC4设计的网站,该网站具有特定的控制器“ ProductionLogs”,在键入URL https://(myapp.com)/ ProductionLogs / GetTop25Logs时 ,它将显示生产服务器的前25个日志。 This is possible only for a user authorized to login to the application.,ie, once they have correctly entered the UserName and Password and gained access into the application. 这仅适用于有权登录应用程序的用户,即,一旦他们正确输入了用户名和密码并获得了对应用程序的访问权。 But I have decided to make this URL available for anyone, without even be able to logging in. Just anyone who types the URL mentioned above, would be able to see the page displaying the latest 25 logs. 但是我决定让任何人都可以使用该URL,甚至无法登录。只有输入上述URL的任何人都可以看到显示最新25条日志的页面。 How to go about? 怎么走?

[Note : I have eliminated the option of 'enabling the directory browsing' in the IIS Server. [注意:我在IIS服务器中取消了“启用目录浏览”选项。 I have also eliminated the option of developing a custom HTTP module.] 我还取消了开发自定义HTTP模块的选项。]

You can use AllowAnonymous attribute, it means that authorization is not required 您可以使用AllowAnonymous属性,这意味着不需要授权

[AllowAnonymous]
  public ActionResult GetLogs() {
    // ...
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM