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; }
}
}
}
查看全文
相关阅读:
ADO.NET 实体框架 资料收集
sql server 根据执行计划查询耗时操作
查看sql server数据库文件信息
TypeScript
使用mustache.js 模板引擎输出html
C#委托多播、Lambda表达、多线程、任务
PID控制器开发笔记之十三:单神经元PID控制器的实现
C语言学习及应用笔记之五:C语言typedef关键字及其使用
君子爱财
PID控制器开发笔记之十二:模糊PID控制器的实现
原文地址:https://www.cnblogs.com/hcfalan/p/500752.html
最新文章
SQL Server 性能优化之——T-SQL NOT IN 和 NOT Exists
【CF878E】Numbers on the blackboard 并查集
【LOJ6077】「2017 山东一轮集训 Day7」逆序对 生成函数+组合数+DP
【CF878D】Magic Breeding bitset
【CF878C】Tournament set+并查集+链表
【CF883B】Berland Army 拓扑排序
【CF884F】Anti-Palindromize 费用流
【CF884D】Boxes And Balls 哈夫曼树
【CF903G】Yet Another Maxflow Problem 线段树
【CF886E】Maximum Element DP
热门文章
【CF886D】Restoration of string 乱搞
【CF900D】Unusual Sequences 容斥(莫比乌斯反演)
【CF887E】Little Brother 二分+几何
【CF889E】Mod Mod Mod DP
【CF888G】Xor-MST Trie树(模拟最小生成树)
【CF888E】Maximum Subsequence 折半搜索
windows 下使用 zip安装包安装MySQL 5.7
几种前端定位方法对比
C#下的Redis 学习
字典查找、linq、foreach、yield等几种查找性能对比
Copyright © 2011-2022 走看看