• C#后台获取页面数据


    using System;  
    using System.Collections.Generic;
    using System.Text;
    using System.Web;

    namespace pub.mo
    {
    public class request
    {
    private request() { }

    /// <summary>
    /// 获取session
    /// </summary>
    /// <param name="_session_name"></param>
    /// <returns></returns>
    public static string session(string _session_name)
    {
    object obj = HttpContext.Current.Session[_session_name];
    return obj == null ? config.empty : obj.ToString();
    }

    /// <summary>
    /// 得到Request.QueryString
    /// </summary>
    /// <param name="_str"></param>
    /// <returns></returns>
    public static string querystring(string _str)
    {
    string s = HttpContext.Current.Request.QueryString[_str];
    return s == null ? config.empty : s;
    }

    /// <summary>
    /// 得到Request.Form
    /// </summary>
    /// <param name="_str"></param>
    /// <returns></returns>
    public static string form(string _str)
    {
    string s = HttpContext.Current.Request.Form[_str];
    return s == null ? config.empty : s;
    }

    /// <summary>
    /// 得到Request.Cookies
    /// </summary>
    /// <param name="_str"></param>
    /// <returns></returns>
    public static string cookies(string _str)
    {
    HttpCookie hc = HttpContext.Current.Request.Cookies[_str];
    return hc == null ? config.empty : hc.Value;
    }

    /// <summary>
    /// 获得当前页面的名称
    /// </summary>
    /// <returns>当前页面的名称</returns>
    public static string page_name()
    {
    string[] urlArr = HttpContext.Current.Request.Url.AbsolutePath.Split('/');
    return urlArr[urlArr.Length - 1].ToLower();
    }

    /// <summary>
    /// 返回表单或Url参数的总个数
    /// </summary>
    /// <returns></returns>
    public static int param_count()
    {
    return HttpContext.Current.Request.Form.Count + HttpContext.Current.Request.QueryString.Count;
    }

    /// <summary>
    /// 得到 Request 的全部
    /// </summary>
    /// <param name="_str"></param>
    /// <returns></returns>
    public static string all(string _str)
    {
    string s = HttpContext.Current.Request[_str];
    return s == null ? config.empty : s;
    }

    #region 获取id
    /// <summary>
    /// 常用 获取ID 默认获取URL id参数 不是数值时返回值为0
    /// </summary>
    /// <returns></returns>
    public static int get_id()
    {
    return fun.is_id(request.querystring("id"), 0);
    }

    /// <summary>
    /// 常用 获取ID 不是数值时返回值为0
    /// </summary>
    /// <param name="_str"></param>
    /// <returns></returns>
    public static int get_id(string _str)
    {
    return fun.is_id(request.querystring(_str), 0);
    }

    /// <summary>
    /// 常用 获取ID
    /// </summary>
    /// <param name="_str"></param>
    /// <param name="_return">不是数值时返回值</param>
    /// <returns></returns>
    public static int get_id(string _str, int _return)
    {
    return fun.is_id(request.querystring(_str), _return);
    }
    #endregion

    }
    }



  • 相关阅读:
    phpmyadmin 设置密码
    php 单向链表反转 reverse (没有空的头结点)
    vue 学习资料
    vue 熟悉项目结构 创建第一个自己的组件
    vue开发环境配置
    vue.js 配置axios 用来ajax请求数据
    javascript 中介者模式 mediator
    PHP 相对路径转换为绝对路径 realpath
    Typescript, ES6
    POST、GET、@RequestBody和@RequestParam区别
  • 原文地址:https://www.cnblogs.com/jhabb/p/2283298.html
Copyright © 2020-2023  润新知