Asp.Net设计源修改自身 [英] Asp.Net design source modifies itself

查看:68
本文介绍了Asp.Net设计源修改自身的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在特定的时间限制后,代码本身如何更改并从页面中删除所有控件并仅留下一条消息,这怎么可能?这是发生在一个网站上,该网站位于专用服务器上.请帮帮我.

How is it possible that after a certain time limit code itself changes and remove all the controls from the page and leave a message only ? It is happening to a website ,website is on a dedicated server. please help me out.

推荐答案

自修改代码?从理论上讲,这是可能的,但这非常复杂(不仅在.NET上),因此我什至不希望讨论它.但我会简单地提到:您可以创建单独的应用程序域,在该域​​中,使用System.Reflection.Emit创建并加载整个程序集以太坊(在这种情况下,您也应该非常了解MSIL)或生成代码并对其进行编译使用CodeDOM,可以通过IPC使用此域,并且在需要再次使用它时,请卸载整个应用程序域并创建一个新的域.您对这些概念中的多少有信心?这将需要对所有这些主题的非常好的知识和信心,并且调试也非常困难.

但是,我认为您现在不需要所有这些深奥的东西,这在一些罕见且真正高级的情况下是有用的.我宁愿认为您的问题是基于对非常基本和简单的编程原理的误解.所有现代编程范例均基于已存储和只读的代码,代码与数据之间的分隔等.它可以追溯到 Turing 机器的历史,而这并不是存储程序计算机.

请参阅:
http://en.wikipedia.org/wiki/Turing_machine [ http://en.wikipedia.org/wiki/Stored-program_computer [ http://en.wikipedia.org/wiki/Self-modifying_code [
Self-modified code? Theoretically speaking, this is possible, but this is extremely complex (not only on .NET), so I don''t want even to discuss it; but I''ll mention in brief: you could create separate Application Domain, in this Domain create and load a whole assembly ether using System.Reflection.Emit (and in this case you also should know MSIL pretty well) or generate the code and compile it using CodeDOM, work with this Domain through IPC, and, when you need to do it again, unload the whole Application Domain and create a new one. How many of those concepts are you confident with? It will require very good knowledge and confidence in all of these topics, and also debugging is pretty difficult.

However, I think you don''t need all these esoteric stuff right now, which is uses in some rare and really advanced cases. I rather think your question is based on misconceptions about very basic and simple programming principles. All the modern programming paradigms are based on stored and read-only code, separation between code and data, etc. It goes back to history as far as the Turing machine, which was not yes a stored-program computer.

Please see:
http://en.wikipedia.org/wiki/Turing_machine[^],
http://en.wikipedia.org/wiki/Stored-program_computer[^].

See also:
http://en.wikipedia.org/wiki/Self-modifying_code[^].

Nevertheless, if we go to mainstream programming, there a fields where modification or generation of code is widely used, but usually this is not a true self-modified code (which is, again, is discouraged). In particular, it happens in ASP.NET and other Web technologies. But this is completely different thing, because generating and generated codes work on the Web on different levels and different tiers. In brief, the server-side code responds to HTTP request and sends an HTTP response with some document like HTTP (most typically), which may contain JavaScript code which is then is executed on client side. This simple mechanism is often misunderstood by CodeProject inquirers who ask how to call JavaScript code by in C#/VB.NET code and visa versa. Strictly speaking, it makes no sense.

First of all, I doubt you really need the timer. You need to explain what effect do you expect and, importantly, why.

It''s hard to understand what exactly you are trying to achieve, but I can suggest that it can be done using regular and usual ASP.NET and JavaScript techniques which you simply need to learn. Perhaps after that you will be able to ask more specific questions.

—SA


这篇关于Asp.Net设计源修改自身的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆