.net ashx 用法? 提示:未能创建类型“HandlerExample.TextBuilder”

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了.net ashx 用法? 提示:未能创建类型“HandlerExample.TextBuilder”相关的知识,希望对你有一定的参考价值。

我创建了 .ashx 和 .ashx.cs

.ashx 中
<%@ WebHandler language="C#" Class="HandlerExample.TextBuilder" codebehind="TextBuilder.ashx.cs"%>

.ashx.cs 中

using System.Web;

namespace HandlerExample

public class MyHttpHandler : IHttpHandler

// Override the ProcessRequest method.
public void ProcessRequest(HttpContext context)

context.Response.Write("<H1>This is an HttpHandler Test.</H1>");
context.Response.Write("<p>Your Browser:</p>");
context.Response.Write("Type: " + context.Request.Browser.Type + "<br>");
context.Response.Write("Version: " + context.Request.Browser.Version);


// Override the IsReusable property.
public bool IsReusable

get return true;


复制错了-_- 那里应该是 public class TextBuilder : IHttpHandler
问题依旧```
我想codebehind类,写成
<%@ WebHandler language="C#" Class="TextBuilder"%> 这个不是目的~ 不过还是谢谢您的回答

参考技术A <%@ WebHandler language="C#" Class="HandlerExample.TextBuilder" codebehind="TextBuilder.ashx.cs"%>
Class="HandlerExample.TextBuilder"换成Class="HandlerExample.MyHttpHandler";

或者这样写
<%@ WebHandler language="C#" Class="TextBuilder"%>

ASP.Net一般处理程序Session用法

1.在aspx和aspx.cs中,都是以 Session["type"]="aaa" 和 string aaa=Session["type"].ToString() 或使用

HttpContext.Current.Session[strSessionName] = strValue;进行读写。

而在一般处理程序ashx中,Session都要使用context.Session,读写方法不变。

2.在ashx文件中,若要对Session进行成功的读写,要添加命名空间和接口,否则context.Session["type"]读出的总是null。

命名空间:using System.Web.SessionState

增加接口:IRequiresSessionState

代码如下:

 

public class pagingQuery : IHttpHandler, IRequiresSessionState

string type =context.Session["type"].ToString();

以上是关于.net ashx 用法? 提示:未能创建类型“HandlerExample.TextBuilder”的主要内容,如果未能解决你的问题,请参考以下文章

未能封送类型,因为嵌入数组实例的长度与布局中声明的长度不匹配

Ext.Net学习笔记09:Ext.Net Store的用法

.Net MVC 提示未能加载文件或程序集

vs调试没问题,iis发布浏览分析其错误,未能加载类型?很急,求大神。

ashx文件不能使用DAL和Model的解决办法

ASP.NET 使用 ASHX 返回 JSON