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; }
}
}
}
查看全文
相关阅读:
Final TFS 2008 Feature List
来看看微软对测试是什么要求
淘宝设计流程
Disable try catch
jQuery validate API
iPhone手机开发平台入门介绍和教程
VSSpeedster Speed up your VS 2010
Where are the SDK tools? Where is ildasm?
效率高的删除语句truncate table [tablename]
修改Hosts去除各站广告
原文地址:https://www.cnblogs.com/hcfalan/p/500752.html
最新文章
Flash8 BitmapData
用C#调用CMD.exe,执行DOS命令,编码FLV
开源测试工具收集
SQL Prompt——数据库脚本自动完成插件
IBM技术培训邀请
QTP学习笔记(1)
IE插件收集
[转载]上班,也可以大格局的上
Ad Hoc Testing、Cross Testing和Smoke Testing
[转载]YAHOO的性能分析工具YSlow
热门文章
Collection of xUnit testing tools
VSTS For Testers读书笔记(25)
QTP学习笔记(2)
[转载]专用软件测试集锦
[转载]拍卖知识
Web开发好助手FireBug(Firefox Plugin)
Cookie测试工具小汇
链接测试工具小汇
VSTS For Testers读书笔记(26)
3ATesting——免费测试视频社区
Copyright © 2011-2022 走看看