zoukankan
html css js c++ java
ASP.NET 开发, PageBase, ModuleBase
using
System;
using
System.Web.UI;
public
class
ApplicationConfiguration : IConfigurationSectionHandler
{
public
Object Create(Object parent,
object
configContext, XmlNode section)
{
//
}
public
static
void
OnApplicationStart(String myAppPath)
{
appRoot
=
myAppPath;
//
init ApplicationConfiguration & call it's Create message
System.Configuration.ConfigurationSettings.GetConfig(
"
ApplicationConfiguration
"
);
}
}
public
class
Global : System.Web.HttpApplication
{
protected
void
Application_Start(Object sender, EventArgs e)
{
//
do something at Application Start
ApplicationConfiguration.OnApplicationStart(Context.Server.MapPath(Context.Request.ApplicationPath));
}
}
/**/
///
<summary>
///
All pages base class
///
</summary>
public
class
PageBase : Page
{
public
const
String KEY_CACHEUSER
=
"
Cache::User
"
;
private
static
String pageSecureUrlBase;
//
for securite http, that is: https
private
static
String pageUrlBase;
private
static
String urlSuffix;
public
PageBase()
{
try
{
string
strPort
=
(Context.Request.Url.Port
==
80
?
""
: String.Format(
"
:{0}
"
, Context.Request.Url.Port));
string
strApp
=
(Context.Request.ApplicationPath
==
"
/
"
?
""
: Context.Request.ApplicationPath);
this
.urlSuffix
=
Context.Request.Url.Host
+
strPort
+
strApp;
this
.pageUrlBase
=
@"
http://
"
+
urlSuffix;
}
catch
{
//
for design time
}
}
public
static
String UrlBase
{
get
{
return
pageUrlBase; }
}
public
UserInfo SignInUser
{
get
{
try
{
return
(UserInfo)Session[KEY_CACHEUSER]; }
catch
{
return
null
;
/**/
/*
for design time
*/
}
}
set
{
if
(
null
==
value)
{ Session.Remove(KEY_CACHEUSER); }
else
{ Session[KEY_CACHEUSER]
=
value; }
}
}
protected
override
void
OnError(EventArgs e)
{
//
todo your error handle code here
//
..
//
and determind if call base OnError message or not
//
base.OnError(e);
}
}
/**/
///
<summary>
///
All user controls base class
///
</summary>
public
class
ModuleBase : UserControl
{
private
String basePathPrefix;
public
String PathPrefix
{
get
{
if
(
null
==
basePathPrefix)
{ basePathPrefix
=
PageBase.UrlBase; }
return
basePathPrefix;
}
set
{
basePathPrefix
=
value;
}
}
public
UserInfo SignInUser
{
get
{
try
{
return
(UserInfo)Session[PageBase.KEY_CACHEUSER]; }
catch
{
return
null
;
/**/
/*
for design time
*/
}
}
set
{
if
(
null
==
value)
{ Session.Remove(PageBase.KEY_CACHEUSER); }
else
{ Session[PageBase.KEY_CACHEUSER]
=
value; }
}
}
}
查看全文
相关阅读:
CSS: 三栏布局
CSS: 实现两栏布局,左边固定,右边自适应的4种方法
css清除浮动
浏览器解析时间线
@Valid解决无法校验List问题
Docker+Jenkins+Git+Maven实现Springboot项目自动化部署
Git安装(CentOS)
Jenkins安装
Docker安装(Centos)
Maven安装(Linux)
原文地址:https://www.cnblogs.com/hcfalan/p/500752.html
最新文章
线性表
MFC控件篇
TOJ3067: 求最大值II
TOJ1301: 统计同成绩学生人数
近期有用的代码
关于Object.assign与 JSON.parse(JSON.stringify())
ajax传值问题
redux学习
wap移动端开发总结
react生命周期的理解
热门文章
js监听窗口关闭的事件写法
前端分页原理
axios的基本用法~~
IE 8兼容小妙招~~
JS: DOM笔记
Set实现并集交集差集
JS:立即执行函数笔记
link 和 @import的区别
简单类型数组去重的若干方法
减少http请求的方法
Copyright © 2011-2022 走看看