Mixing ASP.NET with ASP

This might be a crazy question (I'm somewhat new to ASP.NET). But is it possible to mix ASP.NET code with classic ASP, for example. inline form created in ASP.NET on a classic ASP page?

+7
source share
3 answers

No you can not *

asp pages are simple, simple pages that actually run stand-alone scripts on the server side, and the server returns the result. Each page is one.

asp.net pages are a complete program that are linked to each other because they work under the same pool, compile them all together in the same directory with many subdirectories, have special directories and other parameters. The pool in which the pages work, processes some common data, session states, and many others.

So, you can have a complete asp.net setup for your site that will launch it first, and then you can probably use some asp page to do the extra work until you transfer them all to asp.net

So, both have no relative, so in the simple answer you cannot insert any of one from the other .

Ways to exchange data between asp and asp.net

  • You can use iframes to load one page into another, but they are still different and I don't like this idea.
  • You use some ajax tricks to receive and send data. Not a great idea.
  • You can also use a common database for data exchange.
  • You can use the same cookies to share data.
  • You cannot have the same session data (except for a special library for the session like groat.com).
  • You can share files.

* Except that the code is as simple as

<% IF Len(SomeString) < 3 then %> Ok something here <% end if %> 

In this case, the code is executed on both pages by a simple launch, but they are not built in by asp in asp.net, they completely display one page in one of two.

The #include directive is valid for both, but on asp.net it is not going to compile the included file as on asp.

They have a common way to enter the code, but they are completely different, and you need to start diluting the different ones when you go from asp to asp.net

+7
source

As a rule, the answer to your question is no.

However, in some cases, it may be possible to display part of the ASP.net page and then place the result on the ASP page.

I experimented with this a bit last week using AJAX.

Here is what you can do.

Suppose you have an ASP.net page with the form that you want to display on the ASP page.

1) Create an ASP.net page with the form and wrap it in ASP: Panel - give it an identifier: pnlForm 2) In the ASP.net code, enter the following code in Page_Load : pnlForm.RenderControl() .

 System.IO.StringWriter stringWriter = new System.IO.StringWriter(); HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter); pnlReport.RenderControl(htmlWriter); Response.Write(stringWriter.ToString()); 

3) Add the following code snippet to the end of the code:

 // This snippet is neccessary to get ASP.net to render the report outsisde the page to write to an Excel spreadsheet. public override void VerifyRenderingInServerForm(Control control) { return; } 

4) Create an empty div on your classic ASP page - give it the identifier formDiv .

5) On the classic ASP page, use jQuery.ajax to retrieve the form and place it on the classic ASP page:

 $.ajax({ type: "GET", url: "myASPdotNetpage.aspx", success: function(response) { $('#formDiv').html(response); } }); 

As you can imagine, this is not exactly how the framework is supposed to be used, but if you really need to display some ASP.net and put it somewhere else (for example, on an ASP page or even a spreadsheet), you can at least grab HTML.

+2
source

You can not. The main problem is that ASP and ASP.NET work in different processes. You may have a separate ASP page in an ASP.NET application, but you will not be able to share any code between them. In essence, you would have two applications running in the same directory. It is not possible to transfer data stored in one process (for example, session data).

-one
source

All Articles