8

I am working on a mobile site that uses .aspx for the pages; however, I am transferring information from older .asp pages. These .asp pages are reading database connections, and I am not clear how to convert these into .aspx pages without running into config errors that are unclear to me in fixing.

Is it bad practice to mix .asp and .aspx pages in a site? If not, how can I learn to better understand the conversion differences from .asp database connections to .aspx? This is the only obstacle I have going on at the moment with this site, and I would love to find a solution soon as I've been stuck here for a while.

The site works, but I would like to be consistent with the .aspx set up in pages. I appreciate any help you may have to offer, thank you.

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
creativeedg10
  • 691
  • 1
  • 11
  • 24

2 Answers2

10

You can absolutely mix ASP pages with ASP.NET pages. I've done it for internal sites where we didn't have time to redesign, but needed to add some functionality. Note that you can't share session state between the two types of pages (I worked around this using cookies) but the two pages can live together in the same web site without an issue.

Often ASP pages will have database connections kept in the global.asa file or perhaps in an include file, or even right within the asp pages themselves. It would be helpful as you migrate functionality to have all those connections in one logical place.

There is no straight conversion to ASP.NET from ASP, and if you don't have much experience yet with ASP.NET it would be worthwhile to explore some samples / tutorials to get an understanding of how an ASP.NET Web site works. There are lots of options for how you connect to your database. Have a look at www.asp.net to learn about them.

Ken Pespisa
  • 21,989
  • 3
  • 55
  • 63
  • I was reading a topic similar to this regarding redirects. Any thought about redirecting the pages to each other? – creativeedg10 Apr 22 '11 at 17:24
  • How about reading an HTML file in an ASP.NET page? I would think that this code wouldn't cause issue from the conversion, but maybe I'm missing a read in something: '<% Response.Write(getFilesContent("page.htm")) %>' – creativeedg10 Apr 25 '11 at 18:45
  • @creativeedg10 - redirects will make sense as the ASP page goes away and gets replaced by the ASPX page. Just make sure to make them permanent redirects (301). – Ken Pespisa Apr 27 '11 at 01:12
  • @creativeedg10 - You can read an HTML file in ASP.NET. That code might work depending on the implementation of the getFilesContent method. Normally, though, you'd do that kind of work in a code-behind page and output it to an control. Sounds like another question for Stack Overflow :) – Ken Pespisa Apr 27 '11 at 01:14
  • @Ken - thanks for your help. I'm currently in the process of just totally converting to asp.net from scratch. It's tedious, but there is a good groove going so it looks like I'm going with this right now. I was going to do the redirect, but I decided that since I want to use .net from here forward, might as well convert everything over. – creativeedg10 Apr 30 '11 at 12:02
  • @creativeedg10 - That's good to hear. In the projects where I had to mix the technologies, I would have much rather started over, but alas that wasn't an option. You'll be much happier dealing with one technology, and it will surely be easier to learn ASP.NET this way. – Ken Pespisa May 02 '11 at 01:04
  • @Ken That's what I'm hoping. I definitely have a lot more to learn, but it's actually pretty fun so far :) – creativeedg10 May 02 '11 at 11:53
9

You can have the two running together. It's not necessarily a bad practice to mix the two, but here can be some technical things that you'll have to work out. Since it sounds like you're trying to convert a classic ASP site to ASP.NET, if there are not too many pages, I'd probably try to figure out the conversion issues so that all of your pages are running on ASP.NET.

Otherwise if you do want to run ASP and ASP.NET side by side, if your website has session state or authentication and you need that shared by both asp and asp.net pages, then you need to ensure that you have a strategy to handle that kind of stuff. This thread details session management issues to consider when running ASP with ASP.NET, for example: Classic ASP and ASP.NET Integration.

Community
  • 1
  • 1
Shan Plourde
  • 8,528
  • 2
  • 29
  • 42