简体   繁体   English

从浏览器可见的ASP.NET代码背后?

[英]asp.net code-behind visible from browser?

Can someone see the code-behind of an .aspx website from a browser? 有人可以从浏览器中看到.aspx网站的代码吗?

I have been told it is possible but i cant really find a way of doing it , viewing the page source only shows the presentation page.. 有人告诉我这是有可能的,但我真的找不到解决办法,查看页面源仅显示演示页面。

So is there a way of doing it ? 那么有办法吗? and how? 如何?

thank you 谢谢

No, it is not possible to see the codebehind without physical or remote access to the server itself. 不,如果没有对服务器本身的物理或远程访问,就不可能看到背后的代码。

You could also in theory misconfigure the IIS server to display the source files, and that would cause them to be displayed, rather than compiled, but no idea why anyone would do that. 从理论上讲,您还可以错误地配置IIS服务器以显示源文件,这将导致显示而不是编译它们,但不知道为什么有人这样做。 IIS by default will not display them. IIS默认情况下不会显示它们。

By default, IIS shows parts of your code (aspx or code-behind) when an exception occurs - along with the call stack of the exception. 默认情况下,发生异常时,IIS会显示部分代码(aspx或后台代码)以及该异常的调用堆栈。 Any serious ASP.NET application hides this information from users by using specific error handlers to show the error information in another (often more user-friendly) format. 任何严重的ASP.NET应用程序都会使用特定的错误处理程序以其他(通常是更用户友好的)格式显示错误信息,从而向用户隐藏此信息。

As others mentioned, it's not normally possible to see the code, as it's a server-side handler, compiled and run on the server, while client only sees the HTML output. 正如其他人提到的那样,通常看不到代码,因为它是在服务器上编译并运行的服务器端处理程序,而客户端只能看到HTML输出。

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

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