0

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 ?
1
  • Do you want the 'global' function in the classic ASP or the ASP.net? If it's the classic part of the site, then include files or the global.asa are your only options I think. Commented Feb 14, 2014 at 16:16

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot for the amazing helpful answer. The code is in a "single-file" page model. I guess I will follow your advice and start with an empty VS project. It's better for the long term

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.