zoukankan      html  css  js  c++  java
  • asp.net 读取一个文本文件,并输出到网页显示 通过 一般处理程序实现

    asp.net 读取一个文本文件,并输出到网页显示 通过 一般处理程序实现

    用这个可以做模板首页进行输出,也可以自已自定义进行扩展

        //得到读取到的文本到string中
    
        string resultText = System.IO.File.ReadAllText(filePath);
    public class RedFileSend : IHttpHandler
    
    {
    
      public void ProcessRequest(HttpContext context)
    
      {
    
        //从服务器相对路径中得到文件真实路径
    
        string filePath = context.Server.MapPath("/temp/test1.html");
    
        //得到读取到的文本到string中
    
        string resultText = System.IO.File.ReadAllText(filePath);
    
    
        //设置MIME类型
    
        context.Response.ContentType = "text/plain";
    
        //进行输出
    
        context.Response.Write(resultText);
    
      }
    
    
      public bool IsReusable
    
      {
    
        get
    
        {
    
          return false;
    
        }
    
      }
    
    }
  • 相关阅读:
    Windows中的库编程(三、函数调用约定 Calling Convention)
    weui
    js 压缩图片
    django 跨域访问
    html5
    有用的网站
    Chrome
    srpingBoot配置多环境配置文件
    Mysql在查询时不区分大小写
    [CentOS7]Nginx 1.20.1不支持四层负载
  • 原文地址:https://www.cnblogs.com/webenh/p/5743058.html
Copyright © 2011-2022 走看看