Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 8 of 8

Thread: missing source global.asax.cs

  1. #1
    mudge is offline Junior Member
    Join Date
    Feb 2009
    Posts
    10

    Default missing source global.asax.cs

    Part of our application was a custom membership provider using FormsAuthentication. We made modifications to the global.asax.cs begin_request in version 7.0.2.3. we could not deploy that without upgrading to 7.1.1.0 because of an asp.net compatibility issue. In the new version, source code for global.asax.cs was not supplied and the ASPDNSF membership logic is now compiled.

    I have attempted to port this part of our application using the suggested work around published in the knowledge base article id 379.

    Is there a way to receive source code for global.asax.cs or is there a more appropriot solution to implement custom membership authentication.
    Last edited by mudge; 03-19-2009 at 08:19 PM.

  2. #2
    mudge is offline Junior Member
    Join Date
    Feb 2009
    Posts
    10

    Default

    Please disregard previos post... I have found another solution.
    Thanks

  3. #3
    ASPDNSF Staff - Jon's Avatar
    ASPDNSF Staff - Jon is offline Senior Member
    Join Date
    Sep 2004
    Posts
    11,419

    Default

    You can create an HttpHandler to substitute for the lack of a Global.asax.cs file. Save the following code as AppEvents.cs in your \web\app_code folder:

    Code:
    using System;
    using System.Web;
    using System.Web.SessionState;
    
    public class AppEvents : IHttpModule
    {
        public AppEvents() {}
        static bool firstTime = true;
    
        public void Init(HttpApplication application)
        {
            SessionStateModule session = application.Modules["Session"] as SessionStateModule;
    
            //application.BeginRequest += new EventHandler(Application_BeginRequest);
            //application.AuthenticateRequest += new EventHandler(Application_AuthenticateRequest);
            //application.PostAuthenticateRequest += new EventHandler(Application_PostAuthenticateRequest);
            //application.AuthorizeRequest += new EventHandler(Application_AuthorizeRequest);
            //application.PostAuthorizeRequest += new EventHandler(Application_PostAuthorizeRequest);
            //application.ResolveRequestCache += new EventHandler(Application_ResolveRequestCache);
            //application.PostResolveRequestCache += new EventHandler(Application_PostResolveRequestCache);
    
            if (session != null)
            {
            //    session.Start += (new EventHandler(Session_Start));
            }
    
            //application.AcquireRequestState += new EventHandler(Application_AcquireRequestState);
            //application.PostAcquireRequestState += new EventHandler(Application_PostAcquireRequestState);
    
            //application.PreRequestHandlerExecute += new EventHandler(Application_PreRequestHandlerExecute);
            //application.PostRequestHandlerExecute += new EventHandler(Application_PostRequestHandlerExecute);
            //application.ReleaseRequestState += new EventHandler(Application_ReleaseRequestState);
            //application.PostReleaseRequestState += new EventHandler(Application_PostReleaseRequestState);
            //application.UpdateRequestCache += new EventHandler(Application_UpdateRequestCache);
            //application.PostUpdateRequestCache += new EventHandler(Application_PostUpdateRequestCache);
            //application.EndRequest += new EventHandler(Application_EndRequest);
            //application.PreSendRequestHeaders += new EventHandler(Application_PreSendRequestHeaders);
            //application.PreSendRequestContent += new EventHandler(Application_PreSendRequestContent);
            //application.Disposed += new EventHandler(Application_Disposed);
            //application.Error += new EventHandler(Application_Error);
    
            if (firstTime)
            {
            //    Application_Start();
                firstTime = false;
            }
        }
    
        public void Dispose() {}
    
        void Application_Start()
        {
            throw new NotImplementedException();
        }
    
        void Application_BeginRequest(object sender, EventArgs e)
        {
            throw new NotImplementedException();
        }
    
        void Application_AuthenticateRequest(object sender, EventArgs e)
        {
            throw new NotImplementedException();
        }
    
        void Application_PostAuthenticateRequest(object sender, EventArgs e)
        {
            throw new NotImplementedException();
        }
    
        void Application_AuthorizeRequest(object sender, EventArgs e)
        {
            throw new NotImplementedException();
        }
    
        void Application_PostAuthorizeRequest(object sender, EventArgs e)
        {
            throw new NotImplementedException();
        }
    
        void Application_ResolveRequestCache(object sender, EventArgs e)
        {
            throw new NotImplementedException();
        }
    
        void Application_PostResolveRequestCache(object sender, EventArgs e)
        {
            throw new NotImplementedException();
        }
    
        void Session_Start(object sender, EventArgs e)
        {
            throw new NotImplementedException();
        }
    
        void Application_AcquireRequestState(object sender, EventArgs e)
        {
            throw new NotImplementedException();
        }
    
        void Application_PostAcquireRequestState(object sender, EventArgs e)
        {
            throw new NotImplementedException();
        }
    
        void Application_PreRequestHandlerExecute(object sender, EventArgs e)
        {
            throw new NotImplementedException();
        }
    
        void Application_PostRequestHandlerExecute(object sender, EventArgs e)
        {
            throw new NotImplementedException();
        }
    
        void Application_ReleaseRequestState(object sender, EventArgs e)
        {
            throw new NotImplementedException();
        }
    
        void Application_PostReleaseRequestState(object sender, EventArgs e)
        {
            throw new NotImplementedException();
        }
    
        void Application_UpdateRequestCache(object sender, EventArgs e)
        {
            throw new NotImplementedException();
        }
    
        void Application_PostUpdateRequestCache(object sender, EventArgs e)
        {
            throw new NotImplementedException();
        }
    
        void Application_EndRequest(object sender, EventArgs e)
        {
            throw new NotImplementedException();
        }
    
        void Application_PreSendRequestHeaders(object sender, EventArgs e)
        {
            throw new NotImplementedException();
        }
    
        void Application_PreSendRequestContent(object sender, EventArgs e)
        {
            throw new NotImplementedException();
        }
    
        void Application_Disposed(object sender, EventArgs e)
        {
            throw new NotImplementedException();
        }
    
        void Application_Error(object sender, EventArgs e)
        {
            throw new NotImplementedException();
        }
    }

    Step 1; I have all of the event handler registrations commented-out. If you want to handle one of the events, simply uncomment that handler registration, then add your code to the corresponding handler method.


    Step 2; let your website know about the module by adding an entry into the < httpModules > section of web.config:
    Code:
    < add name="AppEvents" type="AppEvents, App_code" />
    This technique behaves exactly like the events inside Global.asax.cs.
    Jon Wolthuis

  4. #4
    mudge is offline Junior Member
    Join Date
    Feb 2009
    Posts
    10

    Default

    Thank you for the sample - this will work well for me

  5. #5
    doktorhallam is offline Member
    Join Date
    Jan 2009
    Posts
    66

    Default

    if i understand this correctly, it looks as though this allows us to "add" to the existing application event logic.

    if that is correct, is there any way to use methods, members, functions, etc. that are already in the logic? is there any way to determine what may be available to us? or is nothing available and to add-on we simply need complete blocks of logic? also, aside from causing compile errors, is there any way to know any variable/function/property names so that we do not accidentally duplicate and become ambiguous?

    thanks in advance.

    added note: and just to clarify, the above is if in fact we are "adding" to the existing logic, as opposed to "replacing" it.

  6. #6
    ASPDNSF Staff - Jon's Avatar
    ASPDNSF Staff - Jon is offline Senior Member
    Join Date
    Sep 2004
    Posts
    11,419

    Default

    Sure, any method, member, or function that is already in the logic is available to you, as all external AdNSF projects are already "referenced" by the website. I'm hoping you have source code, as we don't publish how our methods "operate"; they are covered by copyright. But if they are declared "public", you can certainly call / read / write to them.

    To prevent variable naming clashes, I'd suggest you place your code in a unique Namespace.
    Jon Wolthuis

  7. #7
    mc9000 is offline Member
    Join Date
    Aug 2007
    Posts
    83

    Default

    Anyone have the VB.NET version of this?
    I ran the code on 3 different online code converters, but apparently the delegates/events/definitions etc do not convert directly to VB.NET.

    I really need a book or something on C# (C syntax reminds me of the old HP RPN handheld calculators - it's probably all good, just bass-ackwards)

  8. #8
    virtualtap is offline Senior Member
    Join Date
    May 2007
    Posts
    171

    Default

    Hi I am looking at this option and I have created the AppEvents.cs and modified the web.config as suggested.
    I have an item which I need loaded in the void Application_Start()
    When I place a breakpoint at void Application_Start. it says this break point will not be hit no symbols have been loaded.

    when I go to the solution properties and click on debug Source files
    the AppEvents.cs file is in the box that says Do not look for these source files.

    I have no idea why or how to resolve. any pointers would be great.

    Thanks!
    MSX