Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I specify an Init module?

Status
Not open for further replies.

cwadams1955

Programmer
Jan 21, 2008
52
0
0
CA
I'm starting my first ASP.NET project, and intended to model parts of it on an existing project. The existing project has a module, "ModInit.vb" which contains database connection information, like this:

Code:
Module ModInit

    'Development Connect Strings
    Public SQLDBConn1 As String = "Persist Security Info=False;Server=MyServer;Database=MyDataBase;User ID=Admin;password=password;Integrated Security=false"
Note that this is outside of any subroutine or function residing in the module.

On the original application, I can set a breakpoint and see that this code is being entered after the Global.asx module's "Application_Start" sub exits. But on my application, this ModInit module never hits, and I can't find anything in the settings or code in the original application that instructs the application to use that module - as far as I can tell, my app is set up the same as the original. What am I missing here? Thanks for any assistance.
 
Modules aren't used in ASP.NET applications, they are for windows programs. What you want to do is store all your connection information in the Web.Config file.
 
That may be, but the ModInit module is running in the original application, which certainly is done in ASP.NET. I see the point of putting the connect string info in the Web.Config file, and I think I'll do that, but I'd still like to figure out why this module runs in one app and not in the other. They're currently both in the same inetpub folder on my development machine, will be using the same SQL Server instance, and as far as I can tell, they're set up the same way. I've done a search on the original project and can't find anywhere that module is being referenced, so there must be something somewhere telling the app to use it.
 
I'm lobbing a hail mary here, but when you searched, did you use the "find in files" search, or make sure that the "search hidden text" option was checked in search options?

Unless the global.asax file calls it itself or some other module or page calls it, there is nothing about that name that would make it get called by .Net automatically. There must be a call to that ModInit module somewhere that you haven't found.

----------------------------------------

TWljcm8kb2Z0J3MgIzEgRmFuIQ==
 
Yep, I used those search options. There are also a couple of user-defined functions in the ModInit module that I thought might be getting called at startup, but I can't find anything doing that, either. They are used in the application, but not until one of the user forms gets posted back. I even put a line in a dummy form with a call to one of the procedures to see if the mere presence of a call would trigger that module, but - nothing.

I guess it really doesn't matter, since I can accomplish the same thing in other ways, but I'd really like to figure out how this thing is being fired. I hate stuff that happens for no apparent reason.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top