Cornwell
Cornwell

Reputation: 3410

Add custom namespace to web.config?

I'm working in a Classic ASP \ ASP.net hybrid (old website, no possibility of being rewritten to MVC). I want to create a function that can be used in several .aspx files. There is no Visual Studio project file, no app_code folder, etc.

I have 2 questions:

  1. Is there any way to create a "global" function without having to resort to global.asa ?
  2. Any tips on how to upgrade the website to be fully ASP.net ?

Upvotes: 0

Views: 199

Answers (1)

John
John

Reputation: 4638

This won't completely answer your question but I hope it helps.

Presumably what you have is a Classic ASP site with some asp.net files which were added subsequently. Do your .aspx pages use the code behine or the code in page model?

Classic ASP predates the concept of the VS project - you just start with an empty root directory and add some files, usually starting with your landing page. You can also create individual ASP.net pages without them being part of a project.

Global.asa is where global Classic ASP variables are stored. Global.asax is the direct counterpart in asp.net. If you want a function to ba available to several .asp pages then the standard approach is to put it in a separate file and use the include directive. You could take the same approach with your .aspx pages, which should support the include file directive. It's perfectly possible to build an asp.net page along the same lines as a Classic page with your C#/VB.net code either inside <% %> or a <script runat="server"> tag, you just don't see it very often

To get the site closer what you're familiar with, I think you may need to create an empty VS project, probably webforms rather than MVC, and recreate your aspx pages as project files which can use stuff in the app data folder etc, then import your classic pages and use them as they are until you rewrite them in .net

Upvotes: 1

Related Questions