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
}
}