本文整理汇总了C#中HttpApplication类的典型用法代码示例。如果您正苦于以下问题:C# HttpApplication类的具体用法?C# HttpApplication怎么用?C# HttpApplication使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HttpApplication类属于命名空间,在下文中一共展示了HttpApplication类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
public void Init(HttpApplication context)
{
context.BeginRequest +=
(new EventHandler(this.Application_BeginRequest));
context.EndRequest +=
(new EventHandler(this.Application_EndRequest));
}
示例2: InitApplication
internal static void InitApplication(HttpApplication application)
{
// We need to run StartApplication first, so that any exception thrown during execution of the StartPage gets
// recorded on StartPage.Exception
StartApplication(application);
InitializeApplication(application);
}
示例3: LoadModules
/* stolen from the 1.0 S.W.Config ModulesConfiguration.cs */
internal HttpModuleCollection LoadModules (HttpApplication app)
{
HttpModuleCollection coll = new HttpModuleCollection ();
Type type;
foreach (HttpModuleAction item in Modules){
type = HttpApplication.LoadType (item.Type);
if (type == null) {
/* XXX should we throw here? */
continue;
}
IHttpModule module = (IHttpModule) Activator.CreateInstance (type,
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance,
null, null, null);
module.Init (app);
coll.AddModule (item.Name, module);
}
/* XXX the 1.x config stuff does this
* indirectly.. I'm not sure we want to do it
* here, but this keeps things working in much
* the same fashion in 2.0-land. */
{
IHttpModule module = new DefaultAuthenticationModule ();
module.Init (app);
coll.AddModule ("DefaultAuthentication", module);
}
return coll;
}
示例4: Init
public void Init (SessionStateModule module, HttpApplication context, SessionConfig config)
{
string connectionTypeName;
string providerAssemblyName;
string cncString;
this.config = config;
GetConnectionData (out providerAssemblyName, out connectionTypeName, out cncString);
if (cncType == null) {
Assembly dbAssembly = Assembly.Load (providerAssemblyName);
cncType = dbAssembly.GetType (connectionTypeName, true);
if (!typeof (IDbConnection).IsAssignableFrom (cncType))
throw new ApplicationException ("The type '" + cncType +
"' does not implement IDB Connection.\n" +
"Check 'DbConnectionType' in server.exe.config.");
}
cnc = (IDbConnection) Activator.CreateInstance (cncType);
cnc.ConnectionString = cncString;
try {
cnc.Open ();
} catch (Exception exc) {
cnc = null;
throw exc;
}
}
示例5: Init
/// <summary>
/// Initializes a module and prepares it to handle requests.
/// </summary>
/// <param name="context">An <see cref="T:System.Web.HttpApplication"></see> that provides access to the methods,
/// properties, and events common to all application objects within an ASP.NET application</param>
public void Init(HttpApplication context)
{
context.PostRequestHandlerExecute += new EventHandler(context_PostRequestHandlerExecute);
SessionStateModule session = (SessionStateModule)context.Modules["Session"];
session.End += new EventHandler(session_End);
session.Start += new EventHandler(session_Start);
}
示例6: Init
/// <summary>Init(実装必須)</summary>
/// <remarks>
/// ・BeginRequest :要求処理の開始前に発生
/// ・AuthenticateRequest :呼び出し元を認証
/// ・AuthorizeRequest :アクセスチェックを実行
/// ・ResolveRequestCache :キャッシュから応答を取得
/// ・AcquireRequestState :セッション状態をロード
/// ・PreRequestHandlerExecute :要求をハンドラオブジェクトに送信する直前に発生
/// ・PostRequestHandlerExecute :要求をハンドラオブジェクトに送信した直後に発生
/// ・ReleaseRequestState :セッション状態を保存
/// ・UpdateRequestCache :応答キャッシュを更新
/// ・EndRequest :処理の終了後に発生
/// ・PreSendRequestHeaders :バッファ内の応答ヘッダーを送信する前に発生
/// ・PreSendRequestContent :バッファ内の応答本体を送信する前に発生
/// </remarks>
public void Init(HttpApplication application)
{
// ASP.NETイベント ハンドラを設定
application.BeginRequest += (new EventHandler(this.Filter));
//application.AuthenticateRequest += (new EventHandler(this.Filter));
//application.AuthorizeRequest += (new EventHandler(this.Filter));
//application.ResolveRequestCache += (new EventHandler(this.Filter));
//application.AcquireRequestState += (new EventHandler(this.Filter));
//application.PreRequestHandlerExecute += (new EventHandler(this.Filter));
//application.PostRequestHandlerExecute += (new EventHandler(this.Filter));
//application.ReleaseRequestState += (new EventHandler(this.Filter));
//application.UpdateRequestCache += (new EventHandler(this.Filter));
//application.EndRequest += (new EventHandler(this.Filter));
//application.PreSendRequestHeaders += (new EventHandler(this.Filter));
//application.PreSendRequestContent += (new EventHandler(this.Filter));
}
示例7: ExecuteStartPageInternal
internal static void ExecuteStartPageInternal(HttpApplication application, Action<string> monitorFile, IVirtualPathFactory virtualPathFactory, IEnumerable<string> supportedExtensions)
{
ApplicationStartPage startPage = null;
foreach (var extension in supportedExtensions)
{
var vpath = StartPageVirtualPath + extension;
// We need to monitor regardless of existence because the user could add/remove the
// file at any time.
monitorFile(vpath);
if (!virtualPathFactory.Exists(vpath))
{
continue;
}
if (startPage == null)
{
startPage = virtualPathFactory.CreateInstance<ApplicationStartPage>(vpath);
startPage.Application = application;
startPage.VirtualPathFactory = virtualPathFactory;
startPage.ExecuteInternal();
}
}
}
示例8: Init
public void Init(HttpApplication context)
{
context.AuthenticateRequest += new EventHandler(context_AuthenticateRequest);
SessionStateModule sessionMod = (SessionStateModule)context.Modules["Session"];
sessionMod.Start += new EventHandler(context_AuthenticateRequest);
}
示例9: ExecuteStartPage
internal static void ExecuteStartPage(HttpApplication application)
{
ExecuteStartPage(application,
vpath => MonitorFile(vpath),
VirtualPathFactoryManager.Instance,
WebPageHttpHandler.GetRegisteredExtensions());
}
示例10: CompressResponse
/// <summary>
/// Compresses the response stream if the browser allows it.
/// </summary>
private static MemoryStream CompressResponse(Stream responseStream, HttpApplication app, string key)
{
MemoryStream dataStream = new MemoryStream();
StreamCopy(responseStream, dataStream);
responseStream.Dispose();
byte[] buffer = dataStream.ToArray();
dataStream.Dispose();
MemoryStream ms = new MemoryStream();
Stream compress = null;
if (IsEncodingAccepted(DEFLATE))
{
compress = new DeflateStream(ms, CompressionMode.Compress);
app.Application.Add(key + "enc", DEFLATE);
}
else if (IsEncodingAccepted(GZIP))
{
compress = new GZipStream(ms, CompressionMode.Compress);
app.Application.Add(key + "enc", DEFLATE);
}
compress.Write(buffer, 0, buffer.Length);
compress.Dispose();
return ms;
}
示例11: WaitForAsyncResultCompletion
public static void WaitForAsyncResultCompletion(IAsyncResult asyncResult, HttpApplication app) {
// based on HttpServerUtility.ExecuteInternal()
if (!asyncResult.IsCompleted) {
// suspend app lock while waiting, else might deadlock
bool needToRelock = false;
try {
// .NET 2.0+ will not allow a ThreadAbortException to be thrown while a
// thread is inside a finally block, so this pattern ensures that the
// value of 'needToRelock' is correct.
try { }
finally {
Monitor.Exit(app);
needToRelock = true;
}
WaitHandle waitHandle = asyncResult.AsyncWaitHandle;
if (waitHandle != null) {
waitHandle.WaitOne();
}
else {
while (!asyncResult.IsCompleted) {
Thread.Sleep(1);
}
}
}
finally {
if (needToRelock) {
Monitor.Enter(app);
}
}
}
}
示例12: Init
public void Init(HttpApplication application)
{
application.BeginRequest +=
(new EventHandler(this.Application_BeginRequest));
application.EndRequest +=
(new EventHandler(this.Application_EndRequest));
}
示例13: InitializeRubyApplicationHooks
private void InitializeRubyApplicationHooks(HttpApplication context)
{
if (_mvcApplication.IsNull()) return;
context.Error += (sender, args) => _mvcApplication.Error(sender, args);
context.AcquireRequestState += (sender, args) => _mvcApplication.AcquireRequestState(sender, args);
context.AuthenticateRequest += (sender, args) => _mvcApplication.AuthenticateRequest(sender, args);
context.AuthorizeRequest += (sender, args) => _mvcApplication.AuthorizeRequest(sender, args);
context.BeginRequest += (sender, args) => _mvcApplication.BeginRequest(sender, args);
context.Disposed += (sender, args) => _mvcApplication.Disposed(sender, args);
context.EndRequest += (sender, args) => _mvcApplication.EndRequest(sender, args);
context.LogRequest += (sender, args) => _mvcApplication.LogRequest(sender, args);
context.PostAcquireRequestState += (sender, args) => _mvcApplication.PostAcquireRequestState(sender, args);
context.MapRequestHandler += (sender, args) => _mvcApplication.MapRequestHandler(sender, args);
context.PostAuthenticateRequest += (sender, args) => _mvcApplication.PostAuthenticateRequest(sender, args);
context.PostAuthorizeRequest += (sender, args) => _mvcApplication.PostAuthorizeRequest(sender, args);
context.PostLogRequest += (sender, args) => _mvcApplication.PostLogRequest(sender, args);
context.PostMapRequestHandler += (sender, args) => _mvcApplication.PostMapRequestHandler(sender, args);
context.PostReleaseRequestState += (sender, args) => _mvcApplication.PostReleaseRequestState(sender, args);
context.PostRequestHandlerExecute += (sender, args) => _mvcApplication.PostRequestHandlerExecute(sender, args);
context.PostResolveRequestCache += (sender, args) => _mvcApplication.PostResolveRequestCache(sender, args);
context.PostUpdateRequestCache += (sender, args) => _mvcApplication.PostUpdateRequestCache(sender, args);
context.PreRequestHandlerExecute += (sender, args) => _mvcApplication.PreRequestHandlerExecute(sender, args);
context.PreSendRequestContent += (sender, args) => _mvcApplication.PreSendRequestContent(sender, args);
context.PreSendRequestHeaders += (sender, args) => _mvcApplication.PreSendRequestHeaders(sender, args);
context.ReleaseRequestState += (sender, args) => _mvcApplication.ReleaseRequestState(sender, args);
context.ResolveRequestCache += (sender, args) => _mvcApplication.ResolveRequestCache(sender, args);
context.UpdateRequestCache += (sender, args) => _mvcApplication.UpdateRequestCache(sender, args);
}
示例14: InitializeRubyApplication
private bool InitializeRubyApplication(HttpApplication context)
{
if (_mvcApplication.IsNotNull()) return false;
_mvcApplication = _rubyEngine.ExecuteFile<MvcApplication>("~/mvc_application.rb", false);
if(_mvcApplication.IsNotNull()) _mvcApplication.Start(context, EventArgs.Empty);
return true;
}
示例15: Init
public void Init (SessionStateModule module, HttpApplication context, SessionConfig config)
{
this.config = config;
RemotingConfiguration.Configure (null);
string cons, proto, server, port;
GetConData (config.StateConnectionString, out proto, out server, out port);
cons = String.Format ("{0}://{1}:{2}/StateServer", proto, server, port);
state_server = (RemoteStateServer) Activator.GetObject (typeof (RemoteStateServer), cons);
}