C # page data retrieval in the background

Source: Internet
Author: User
Using System;
Using System. Collections. Generic;
Using System. text;
Using System. Web;

Namespace Pub.mo
{
Public Class Request
{
Private Request (){}

/// <Summary>
/// Get 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>
/// GET 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>
/// GET 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>
/// GET 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>
/// Get the name of the current page
/// </Summary>
/// <Returns> Name of the current page </Returns>
Public Static String Page_name ()
{
String [] Urlarr = httpcontext. Current. Request. url. absolutepath. Split ( ' / ' );
Return Urlarr [urlarr. Length- 1 ]. Tolower ();
}

/// <Summary>
/// Returns the total number of form or URL parameters.
/// </Summary>
/// <Returns> </returns>
Public Static Int Param_count ()
{
Return Httpcontext. Current. Request. Form. Count + httpcontext. Current. Request. querystring. count;
}

/// <Summary>
/// Get all of the 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 Get ID
/// <Summary>
/// The value returned when the url id parameter is not a numerical value is 0 by default.
/// </Summary>
/// <Returns> </returns>
Public Static Int Get_id ()
{
Return Fun. is_id (request. querystring ( " ID " ), 0 );
}

/// <Summary>
/// When the commonly used retrieved ID is not a value, the return value is 0.
/// </Summary>
/// <Param name = "_ Str"> </param>
/// <Returns> </returns>
Public Static Int Get_id ( String _ Str)
{
Return Fun. is_id (request. querystring (_ Str ),0 );
}

/// <Summary>
/// Common acquisition ID
/// </Summary>
/// <Param name = "_ Str"> </param>
/// <Param name = "_ return"> Return value if it is not a value </Param>
/// <Returns> </returns>
Public Static Int Get_id ( String _ STR, Int _ Return)
{
Return Fun. is_id (request. querystring (_ Str), _ return );
}
# Endregion

}
}
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.