Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6235843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:44:31+00:00 2026-05-24T10:44:31+00:00

As a novice – intermediate C# programmer, my debugging issues surround the most basic

  • 0

As a novice – intermediate C# programmer, my debugging issues surround the most basic elements of C# Program Design. My project is a web-based, computerized trading system. Working with (2) API’s, 1 for pricing and the other for Orders my problem seems to be in code design and issues associated with multiple sessions.

I try to use Delegates for all events.

My current questions regarding Windows Forms and Object

  1. Is this the correct way (or a ‘proper way’) to instantiate class objects & event delegates using aspx pages? (my examples often serve to confuse more than help, I realize).

    public partial class admin_Admin : System.Web.UI.Page
    {
    
     private static Downloader dl = null;
     private SendOrderDelegate sendError;
    
     protected void Page_Load(object sender, EventArgs e)
     {
          if (!Page.IsPostBack)
          {
               if (dl == null)
               {
                    Main();
               }
          }
     }
    
     protected static void Main()
     {
          dl = new Downloader();
          sendOrder = new Steury.Trading.SendOrderDelegate(dl.Order);
      }
    }
    
  2. When and How to use the Main() Method? What is the definition for using Main() in a complex Web Application with multiple programs (Pricing, Orders, BackTesting, Optimization), all running simultaneously and using different aspx pages??

Do I use Main() above for each aspx page, and again for each main Class program… Orders.cs, OrderShort.cs, BacktTest.cs, BackTestShort.cs, Optimize.cs, OptimizeShort.cs, or do I use Main Only for the 2 aspx pages that login to the Pricing and Orders Servers and then maintain static session variables that connect to the proper classes?

As you can tell, I am struggling with these concepts and have not found a resource that goes into detail for very complex scenarios. Most if not all use very simple class examples.. I have found this to be helpful Core C# and .NET http://flylib.com/books/en/4.253.1.1/1/ .

  1. Is there any good advice on when to use the Static Keyword? Should I use it for the Top Level Pages only? I am not deploying a multiple user project at this point.

Any other suggestions would be useful, constructive criticism included.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T10:44:31+00:00Added an answer on May 24, 2026 at 10:44 am

    When and How to use the Main() Method?

    You don’t. Remove it. The Main-functionality (the code you want to run the very first time your whole website is run, i.e. Application), or when a certain user accesses it the first time, i.e. Session) is moved to global.asax. By default, this file is not in your web application project, but you can add it.

    Is this the correct way (or a ‘proper way’) to instantiate class objects & event delegates

    No, it is not. Though the IsPostBack check is good (it means whether or not the page has been posted by a user, i.e., whether or not he clicked a submit button on your page, which posts back to the same page). The thing wrong here is the static main function. Consider every page a class (it is a class, really) and that the system instantiates that class for you. The place for initiation is Page_Init. But many people keep it simple and put that in Page_Load. These special methods are automatically called by the ASP.NET system when the page is loaded.

    Is there any good advice on when to use the Static Keyword?

    That’s not easy to answer. In general, in a web page, you hardly ever use the static keyword, simply because many people and user simultaneously access your pages. However, utility classes and methods can sometimes be static. It’s a total different environment than normal windows applications, which typically run in a protected environment.

    and have not found a resource that goes into detail for very complex scenarios

    There are many great books around on ASP.NET. Some go into very complex scenarios. But considering the current phase you’re in, I’d advice you to stick to simple scenarios to begin with.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a novice programmer and as a part of my project I have
I am a novice-intermediate programmer taking a stab at AJAX. While reading up on
Novice programmer here. I'm writing a program that analyzes the relative spatial locations of
I am a novice programmer who is trying to teach myself to code, specifically
I'm a very novice OCaml programmer so please forgive me if this is a
I'm a Python novice, trying to use pyCurl. The project I am working on
Novice programmer asking first question on stack-overflow. I am writing an app for mac
Novice question here. I'm working on finding every single combination of various string elements,
Novice question: Is it possible to build my project (using BuildEngine or so) if
I'm a novice programmer and have developed a notepad replacement application for my own

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.