请任何人告诉我,这个eroor在asp.net中是什么意思? [英] Please can anyone tell me what does this eroor means in asp.net ?

查看:81
本文介绍了请任何人告诉我,这个eroor在asp.net中是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我在vb.net中有以下课程:

Hi all ,

I have the following class in vb.net :

Imports System.Data
Imports System.Configuration
Imports System.Linq
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.HtmlControls
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Xml.Linq
Imports System.Collections.Generic


Public Class Myhandler
    Inherits System.Web.UI.Page
    Implements IHttpModule

	Private _page As Page = Nothing

	Private temp As Queue(Of String)
	Public Sub New()
		temp = New Queue(Of String)()
	End Sub
	Public Shadows Sub Init(context As HttpApplication) Implements IHttpModule.Init

		AddHandler context.PreRequestHandlerExecute, New EventHandler(AddressOf context_PreRequestHandlerExecute)
	End Sub


	Private Sub context_PreRequestHandlerExecute(sender As Object, e As EventArgs)

		Dim _httpContext As System.Web.HttpContext = System.Web.HttpContext.Current


		If _httpContext IsNot Nothing Then
			_page = TryCast(_httpContext.Handler, System.Web.UI.Page)

			If _page IsNot Nothing Then

				AddHandler _page.Init, New EventHandler(AddressOf _page_Init)

				AddHandler _page.Load, New EventHandler(AddressOf _page_Load)
			Else
				Return
			End If
		Else
			Return
		End If

	End Sub

	Private Sub _page_Init(sender As Object, e As EventArgs)
		Dim hdnGuid As New HiddenField()
		hdnGuid.ID = "hdnGuid"
		If Not _page.IsPostBack Then
			hdnGuid.Value = Guid.NewGuid().ToString()
		End If
		_page.Form.Controls.Add(hdnGuid)
	End Sub

	Private Sub _page_Load(sender As Object, e As EventArgs)
		Dim h1 As HiddenField = DirectCast(_page.Form.FindControl("hdnGuid"), HiddenField)
		Dim currentGuid As New GuidClass()
		currentGuid.Guid = h1.Value
		Dim _httpContext As System.Web.HttpContext = System.Web.HttpContext.Current

		If temp.Contains(Of String)(currentGuid.Guid) Then
			_httpContext.Items.Add("IsRefresh", True)
		Else
			If Not (currentGuid.Guid.Equals(Nothing) OrElse currentGuid.Guid.Equals("")) Then
				temp.Enqueue(currentGuid.Guid)
			End If
			_httpContext.Items.Add("IsRefresh", False)
		End If
	End Sub
End Class



并生成此错误:编译器错误消息:BC30149:类``Myhandler''必须为接口``System.Web.IHttpModule''实现``Sub Dispose()''.

在此先感谢.



And this error is generated:Compiler Error Message: BC30149: Class ''Myhandler'' must implement ''Sub Dispose()'' for interface ''System.Web.IHttpModule''.

Thanks in advance.

推荐答案

我与ASP.NET没有任何关系.这是因为System.Web.IHttpModule具有方法Dispose(还有Init).接口实现规则要求您同时实现这两种方法.做到这一点,但首先要了解原因.请参阅 http://msdn.microsoft.com/en-us/library/system.web .ihttpmodule.aspx [ ^ ].

我还建议您在进入ASP.NET之前先熟悉一下编程,OOP和.NET的基础知识.首先,只需要通过控制台应用程序来熟悉这些内容就可以了.在诸如APS.NET之类的更复杂的领域中走得太远,只会浪费太多时间并造成太多挫败感.

祝你好运,
—SA
I has nothing to do with ASP.NET. This is because System.Web.IHttpModule has the method Dispose (and also Init). The rules for implementation of interfaces require that you implement both methods. Do it, but first learn why. See http://msdn.microsoft.com/en-us/library/system.web.ihttpmodule.aspx[^].

I would also recommend that you became comfortable with basics of programming, OOP and .NET before getting to ASP.NET. Getting familiar with this stuff doing your exercises with just console application at first would be much more appropriate. Going too far in more complex fields like APS.NET you will only loose too much time and create too much frustration.

Good luck,
—SA


这篇关于请任何人告诉我,这个eroor在asp.net中是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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