aspnetrequest相关操作Word文档格式.docx

上传人:b****6 文档编号:22065262 上传时间:2023-02-02 格式:DOCX 页数:11 大小:17.38KB
下载 相关 举报
aspnetrequest相关操作Word文档格式.docx_第1页
第1页 / 共11页
aspnetrequest相关操作Word文档格式.docx_第2页
第2页 / 共11页
aspnetrequest相关操作Word文档格式.docx_第3页
第3页 / 共11页
aspnetrequest相关操作Word文档格式.docx_第4页
第4页 / 共11页
aspnetrequest相关操作Word文档格式.docx_第5页
第5页 / 共11页
点击查看更多>>
下载资源
资源描述

aspnetrequest相关操作Word文档格式.docx

《aspnetrequest相关操作Word文档格式.docx》由会员分享,可在线阅读,更多相关《aspnetrequest相关操作Word文档格式.docx(11页珍藏版)》请在冰豆网上搜索。

aspnetrequest相关操作Word文档格式.docx

参数名称&

/param&

returns&

参数对应的值&

/returns&

staticpublicstringget(stringvarname)

{

stringvarvalue="

"

;

if(httpcontext.current.request[varname]!

=null)

varvalue=httpcontext.current.request[varname].tostring();

returnvarvalue;

}

///getint

defvalue"

staticpublicintgetint(stringvarname,intdefvalue){returnget(varname).toint(defvalue);

///getfloat

staticpublicfloatgetfloat(stringvarname,intdefvalue){returnget(varname).tofloat(defvalue);

#endregion

#regiongetq/getqint/getqfloat

///取url上的参数

参数名&

返回参数&

staticpublicstringgetq(stringvarname)

if(httpcontext.current.request.querystring[varname]!

=null)

varvalue=httpcontext.current.request.querystring[varname].tostring();

///getqint

staticpublicintgetqint(stringvarname,intdefvalue){returngetq(varname).toint(defvalue);

///getqfloat

staticpublicfloatgetqfloat(stringvarname,intdefvalue){returngetq(varname).tofloat(defvalue);

#regiongetf/getfint/getffloat

///取post提交的数据

名称&

返回值&

staticpublicstringgetf(stringvarname)

if(httpcontext.current.request.form[varname]!

=null)

varvalue=httpcontext.current.request.form[varname].tostring();

///getfint

staticpublicintgetfint(stringvarname,intdefvalue){returngetf(varname).toint(defvalue);

///getffloat

staticpublicfloatgetffloat(stringvarname,intdefvalue){returngetf(varname).tofloat(defvalue);

#regionispost/isget

///判断当前页面是否接收到了post请求

是否接收到了post请求&

publicstaticboolispost()

returnhttpcontext.current.request.httpmethod.equals("

post"

);

///判断当前页面是否接收到了get请求

是否接收到了get请求&

publicstaticboolisget()

get"

#region服务器变量名

///返回指定的服务器变量信息

///

strname"

服务器变量名&

服务器变量信息&

publicstaticstringgetserverstring(stringstrname)

if(httpcontext.current.request.servervariables[strname]==null)

return"

returnhttpcontext.current.request.servervariables[strname].tostring();

#regiongetrawurl/isbrowserget/issearchenginesget/getpagename/getqparamcount/getfparamcount/getparamcount/

///获取当前请求的原始url(url中域信息之后的部分,包括查询字符串(如果存在))

原始url&

publicstaticstringgetrawurl()

returnhttpcontext.current.request.rawurl;

///判断当前访问是否来自浏览器软件

当前访问是否来自浏览器软件&

publicstaticboolisbrowserget()

string[]browsername={"

ie"

"

opera"

netscape"

mozilla"

konqueror"

firefox"

};

stringcurbrowser=httpcontext.current.request.browser.type.tolower();

for(inti=0;

i&

browsername.length;

i++){

if(curbrowser.indexof(browsername[i])&

=0)returntrue;

returnfalse;

///判断是否来自搜索引擎链接

是否来自搜索引擎链接&

publicstaticboolissearchenginesget(){

if(httpcontext.current.request.urlreferrer!

=null){

string[]strarray=newstring[]{"

google"

yahoo"

msn"

baidu"

sogou"

sohu"

sina"

163"

lycos"

tom"

yisou"

iask"

soso"

gougou"

zhongsou"

};

stringstr=httpcontext.current.request.urlreferrer.tostring().tolower();

strarray.length;

if(str.indexof(strarray[i])&

///获得当前页面的名称

当前页面的名称&

publicstaticstringgetpagename()

string[]urlarr=httpcontext.current.request.url.absolutepath.split('

/'

returnurlarr[urlarr.length-1].tolower();

///返回表单或url参数的总个数

publicstaticintgetparamcount()

returnhttpcontext.current.request.form.count+httpcontext.current.request.querystring.count;

///getparamcount

publicstaticintgetqparamcount(){return(httpcontext.current.request.querystring.count);

///postparamcount

publicstaticintgetfparamcount(){return(httpcontext.current.request.form.count);

#regiongetcurrentfullhost/gethost/getip/geturl/getreferrer/saverequestfile/getos/getbrowser

///取全ip包括端口

ip和端口&

publicstaticstringgetcurrentfullhost()

httprequestrequest=httpcontext.current.request;

if(!

request.url.isdefaultport)

returnstring.format("

{0}:

{1}"

request.url.host,request.url.port.tostring());

returnrequest.url.host;

///取主机名

publicstaticstringgethost(){returnhttpcontext.current.request.url.host;

///前台url

publicstaticstringgeturl(){returnhttpcontext.current.request.url.tostring();

///来源url

publicstaticstringgetreferrer(){

stringstr=null;

try{

str=getserverstring("

http_referer"

).trim();

if(str.length==0)str=httpcontext.current.request.urlreferrer.tostring();

}catch{}

if(str==null)return"

returnstr;

///保存request文件

path"

保存到文件名&

publicstaticvoidsaverequestfile(stringpath)

if(httpcontext.current.request.files.count&

0)httpcontext.current.request.files[0].saveas(path);

#regiongetip

///取ip

返回ip&

publicstaticstringgetip(){

stringresult=string.empty;

result=httpcontext.current.request.servervariables["

http_x_forwarded_for"

];

if(result!

=null&

amp;

result!

=string.empty){//可能有代理

if(result.indexof("

."

)==-1)result=null;

else{

"

)!

=-1){//有“,”,估计多个代理。

取第一个不是内网的ip。

result=result.replace("

"

).replace("

'

string[]temparyip=result.split("

;

.tochararray());

temparyip.length;

if(temparyip[i].isip()

&

temparyip[i].substring(0,3)!

="

10."

temparyip[i].substring(0,7)!

192.168"

172.16."

returntemparyip[i];

//找到不是内网的地址

elseif(result.isip())//代理即是ip格式

returnresult;

else

result=null;

//代理中的内容非ip,取ip

stringipaddress=(httpcontext.current.request.servervariables["

]!

=null

httpcontext.current.request.servervariables["

=string.empty)

]

:

remote_addr"

if(null==result||result==string.empty)

if(result==null||result==string.empty)

result=httpcontext.current.request.userhostaddress;

#endregion

#regiongetos

///取操作系统

返回操作系统&

publicstaticstringgetos(){

httpbrowsercapabilitiesbc=newhttpbrowse

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 党团工作 > 入党转正申请

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1