zoukankan      html  css  js  c++  java
  • .NET WEB技术小记

    一般处理程序无法使用Session的解决方法

    1. 先引用System.Web.SessionState
    2. 给ProcessRequest方法添加一个要实现的接口IRequirsSessionState

    使用模板文件作为响应的内容

        context.Response.ContentType = "text/html";
        string path = context.Server.MapPath("loginTemplate.htm");//找出静态文件loginTemplate.htm在磁盘的完整路径
        string html = System.IO.File.ReadAllText(path);//读出其内容
        string username="michael";
        html = html.Replace("@username", username);//替换模板文件中的占位符@username
        context.Response.Write(html); //将响应内容输出到浏览器   
    

    如何判断一个后台处理程序是由url发出的请求还是由表单提交而发出的请求

    可以表单中加一个type="hidden"的控件,如:

        <input type="hidden" name="action" value="post" />
    

    在后台处理程序中进行判断,如:

        string isPostBack = context.Request["action"];
        if (string.IsNullOrEmpty(isPostBack))
        {
            //第一次发出的请求,也就是说是由url发出
        }else{
            //由表单提交发出的
        }
    
  • 相关阅读:
    文件操作
    验证进程 及jion方法
    进程笔记
    网络通信名词总结
    网络QQ聊天代码实例
    网络通信 粘包和 缓冲器
    udp
    UVALive 3983 Robotruck (单调队列,dp)
    UVA 10891 Game of Sum (决策优化)
    Uva 10635 Prince and Princess (LCS变形LIS)
  • 原文地址:https://www.cnblogs.com/beast-king/p/10461140.html
Copyright © 2011-2022 走看看