【发布时间】:2011-01-14 04:56:06
【问题描述】:
出于本讨论范围之外的原因(比如将一个 aspx 页面复制到一个目录,这样我们就不必重新构建),我们希望在一个 aspx 页面中实现一个接口。比如说,如果page 是 myPage.aspx,它通常是代码隐藏 mypage.aspx.cs 中实现接口的类。当我做这样的事情时
<%@ Page Language="C#" AutoEventWireup="true" Inherits="ICustomInterface" %>
我收到一个错误
Parser Error Message: 'ICustomInterface' is not allowed here because it does not extend class 'System.Web.UI.Page'.
但是,当不指定 Inherits 属性时,页面不会引发错误。所以默认情况下,当我们不指定Inherits属性时,页面继承自System.web.UI.Page?
我们正在使用 VS2008 Web 应用程序项目并且没有预编译 aspx 页面。我们希望在 HTTPModule(开始请求)中截获对该页面的请求,如果该请求是对 ICustomInterface 类型的页面的请求,我们希望以不同的方式处理它。
如何做到这一点?
【问题讨论】:
标签: asp.net interface implementation httpmodule web-application-project