一直没有搞清楚asp.net页 即aspx页中的代码
编译页面,如何处理前台代码的?IHttpHandler hander = BuildManager.CreateInstanceFromVirtualPath(filePath, typeof(Page)) as IHttpHandler;
hander.ProcessRequest(context);编译页面后,又是如何得到整个页面代码的,即最终显示的html代码?
编译页面,如何处理前台代码的?IHttpHandler hander = BuildManager.CreateInstanceFromVirtualPath(filePath, typeof(Page)) as IHttpHandler;
hander.ProcessRequest(context);编译页面后,又是如何得到整个页面代码的,即最终显示的html代码?
调用相应的DLL解释服务器端脚本 把生成的HTML和JS等以HTTP协议规则发送给客户端浏览器解释
正解,ASPX文件与CS文件是靠Page指令里的CodeFile和Inherits关联起来的
IIS收到.aspx的请求后调用CLR里的aspnet_aspi.dll来进行处理,处理后的HTML页面再由IIS发送到客户端呈现
这个属性可以用来生成静态html,不明白它的原理
我调试找来的代码
有这么一句没整懂
context.Response.Filter = new AspxBoy.BuildHtmlDemo.ToHtmlFilter(context.Response.Filter, path);
我去掉这一句,就不能生成html。
我这样写
ToHtmlFilter h = new AspxBoy.BuildHtmlDemo.ToHtmlFilter(context.Response.Filter, path);
也不能生成html
跟踪调试后发现,这种写法context.Response.Filter = new AspxBoy.BuildHtmlDemo.ToHtmlFilter(context.Response.Filter, path);
会自动调用重写Stream后的Write方法,原理是怎么回事呢?