Skip to main content
 首页 » 编程设计

c#之使用 ashx 用 html 填充 div

2024年02月13日998°冷暖

是否可以使用通用处理程序 (*.ashx) 返回 html,我可以在 div 标记中使用它?

有点像

<div id="foo"> [call my generic handler which returns some html to be used within this div ] </div> 

在这种情况下,它不是图像,而只是 HTML。

谷歌搜索时没有找到任何东西。

请您参考如下方法:

是的,你可以返回类似的东西:

public class CustomFormHandler : IHttpHandler { 
    public void ProcessRequest (HttpContext context) { 
 
        context.Response.ContentType = "text/html"; 
        context.Response.Write("<p>my html</p>"); 
    } 
    public bool IsReusable { 
        get { 
            return false; 
        } 
    } 
}