Converting HTML (or Classic ASP) to ASP.NET - asp.net

I was wondering if there is a way to convert and HTML template to ASP.NET? I am trying to convert a website template that was written in HTML that contains Javascript and CSS files to ASP.NET so I can connect to a SQL Server database.
I have limited coding experience with ASP.NET so any help is appreciated!
I also have access to an ASP template but it is not ASP.net unfortunately.

I'm afraid to say you are going to have to get familiar with .NET for this however I like many others had to do this back in the day... although now you have many other factors like are you going to migrate to a Webforms based ASP.NET application or an ASP.NET MVC application.
You can just put your HTML content into an .aspx page however you are going to have to learn the fundamentals of .NET and perhaps things like ADO.NET, LINQ to SQL, nHibernate to get connected to a database.
This may help, but it is rather old: http://www.asp.net/web-forms/videos/migrating/migrating-from-classic-asp-to-aspnet
Microsoft do have a lot of information to help you make this transition... http://www.asp.net/get-started
Not the best answer I realise but you will have to take on a bit of a learning curve, and who knows, you may end up loving .NET, C#, VB, etc, etc... Trust me, it won't be that hard!

There's no easy way to do what you're asking. You can save it as a .aspx page instead of .html, but you can't magically make it connect to the database without coding adjustments.

Just create a new aspx page and copy the content to the aspx file. You should not face any issue in keeping original Html tags in aspx page, but if you need to do some sort of logic on cs file then you might want to change the Html tags to asp tags. which, again should be easy.
And to connect it to database, may be you would like to connect it from cs file.

Related

ASP.NET websites are compiled but with more HTML markup generated!

Everytime I view the source of ASP.NET website I found alot alot of HTML markup generated. I even tried Visual web Developer and design a simple page and then do the same thing with PHP and I found ASP.NET generates more HTML!
Now, how can ASP.NET be faster if it is generating HTML in this way!
Template generation is a very SMALL cost compared to other things that are going on in a web request. ASP.NET offers a lot more than a straight up PHP page (Session/State management etc) and injects additional markup into the response to help with this.
However, your question in general isn't really a question, if you were to take sometime to understand the difference between a web framework and a language.
ASP.NET controls generate extra markup in exchange for "easing" development

Topics I should learn for converting this Classic-ASP code into ASP.NET? Mainly SQL Server Database Access

So, I have a very simple bit of ASP on my website currently, which you can check out here: http://www.marioplanet.com/catalog.asp
Just ignore the CSS issue for now! :)
Anyway, so, I have a SQL Server table in a database, and I'm pulling some information from it to make a shopping catalog of all my products.
I was wondering if there is any need to convert this to ASP.NET, and if I should, as I'm eager to learn how, which topics of ASP.NET does this include?
I would assume handling data through a SQL Server Database Table?
Also, which ASP.NET framework is best suited for this kind of work? For the most part, the only ASP.NET code I'm going to be using, is going to be handling data from a database. Other than a few conditionals and what not.
Any ideas and suggestions are greatly appreciated!
Thanks!!
If you are comfortable in classic ASP, I wouldn't rush to change it.
However, if I were to convert it, I would lean toward ASP.NET MVC because it is closer to classic ASP than ASP.NET with WebForms.
There are numerous data frameworks. I think LINQ to SQL has a lot of momentum and would be fairly easy to learn coming from a classic ASP background.

Classic ASP to ASP.NET 2.0 conversion

can i have some general advice on converting a classic asp site to asp.net? i've never worked with classic asp before and have only worked with asp.net 2.0 for the past 6 months or so, so this is completely new to me.
i noticed that this site i'm wokring on uses a few 'include' files. i know i should probably take the code from the include files and copy them into their own class files. i've notice that there is no code behind file, that each page is written in it's own file (markup and code). also, and this is kind of throwing me off, there are no event handlers. are there any other helpful nuances between classic and .NET you can mention?
one more question: i've notice in each file in my project that there is some code that is written above the markup, and some more below the markup. it seems it would be better if ALL the code was written above or below the markup, for organizational/readability purposes. unless, there's a reason for this. ???
thanks.
You certainly have a challenge on your hands. As far as comparisons are concerned, MVC is probably closer to classic ASP as it doesn't attempt to abstract the web into an event based structure - but that would just be another thing for you to learn.
Classic ASP is a completely different beast to ASP.NET as you're finding out. Basically each URL resolves to a parent ASP file. That in turn includes other ASP files (they can have different extensions if developer felt like it i.e. ".inc"). These in turn can include other files. It is entirely possible to have the same file included several times - generally ASP engine copes with this however. It is important to remember that all includes are processed to make one big document before any actual ASP processing starts. So once all the includes have been processed, you have one big document. The ASP engine then starts at the top and processes the code line by line. You'll probably have HTML and ASP code all inter-twined, with calls off to proceedures.
If you can program C# or VB then reading an ASP file with that in mind shouldn't be too difficult. At that stage you can begin to tackle the functionality one page at a time. Just remember that in ASP there is also no "post back" or view state concepts. Again this is ASP.NET trying to abstract web programming to represent an event based approach.
Sorry one last thing - some commands such as option explicit in ASP must be the first thing in the parent ASP document, so that must always appear before any other code or markup. After that code and markup can be mixed intogether - resulting in the infamous "tag soup" that ASP will be remembered for.
Take your includes and categorize them:
1) Code functions
2) Template functions
All code functions should be dropped into business object classes or modules. The template functions should be placed into user controls and sequently master pages. I strongly suggest the use of master pages in controlling the templated look of your new project as it will save you a lot of time in managing the site and transferring all of the actual page functionality into the new pages.
ASP is a scripted language where as Asp.Net can be either scripted or compiled. I would recommend choosing a Website Project because this will give you the greatest flexibility in deploying the minutae of the code. A Web Application project will compile everything into a singular .dll file which is easy to deploy, but it leads to a lot of regression testing if/when page code intertwines.
Once you have a templated structure, common classes, data access layer and masterpage/usercontrol structure established, it just becomes a task of going page by page and converting it over to the new code.

Possible to use an ASP page with a master page?

Is it possible to use an ASP page with a master page in ASP.NET?
Unfortunately, not programatically. The closest you could get would be creating a .NET master page and web form, and then embedding your classic asp page via an iFrame.
Are you still having this issue? There is a really old tool to help convert to the early version of .ASP. Unfortunately, I don't believe this is the best practice to convert to the later versions of asp.net. I am working on a project to convert a classic ASP app, with many, many, pages and it is still using recordsets with an old SQL database. I have found that taking each page's "view source" results and creating a new page inside my VS2010, web project, using a master page to help keep the results consistent across the site works pretty good.
The only issue is that this is very tedious and requires frequent testing to insure the page is consistent with the old page.
Back to the original issue of using Classic ASP in a new ASP.net app, I believe the issue may be resolved by having two application pools, and two applications separate apps on the web server, and referencing the old pages as a link in an iframe. Just a thought...
Cheers
I don't think so. Are you talking about classic asp? I just found this discussion.
[Edit]
Maybe you can. Check this out.
[/edit]
I recommend creating a new ASP.NET MVC (as opposed to WebForms) project and converting all your ASP pages into ASP.NET in a single exercise.
Performing a phased conversion and running a mix of ASP and ASP.NET will cause you sorts of headaches and, although it may be perceived to deliver more quickly, the total cost is likely to be higher than a one-off conversion exercise.
ASP.NET MVC lends itself to conversion from ASP far more nicely than ASP.NET WebForms in most cases.
You can use master page in asp.net mvc as a shared resource.
I am having this problem at the moment. Some of the ASP pages are so complex that changes to the site's functionality are way more important than porting some of the more difficult pages.
If you have to work side by side for the time being, slowing moving them over do the following.
Get your business logic in a .NET assembly, "tlbimp.exe" it so it can interop with ASP and then move your page decisions to communicate with this component. This way you can now share business logic and therefore only have the UI data to move.
Pass Session/QueryString data via the DB, not by query string. This means that you should commit your Session/QueryString data to XML or Key/Value pair and store it in the DB (with an expiry time). Then redirect to your ASP with a GUID. There is a potential for someone to hijack the session by grabbing a previous GUID. Therefore have a scheduled job run regularly to clear out session data older than 1 minute.
When transferring to/from .NET, try and make the pages perform their operations before transferring across boundaries. This way the pages can be ported easier. For example lets say .NET displays the order and ASP does the search for a product & adds it to your shopping basket. Make sure that the operations are separate, instead of passing the product across via query string parameters. This way you can then do something like redirect to the order page via query string parameters - http://...../Order.aspx?id= (so long as your user has permission to view the order).
Make sure your ASP code is using stored procedures and not inline SQL as this means code reuse is easier.
I have found creating a dedicated redirect.asp and Redirect.aspx pages are useful as you can see the data passing across the boundaries - its easier for debugging but you'll hear lots of clicks as a user ASP -> ASP_REDIRECT -> ASP.NET_REDIRECT -> ASP.NET.
Globalization is a major problem and has caused problems with our users. Changing a language and redirecting to/from the site in ASP has sometimes caused their language to default to English - and English to Chinese!
There aren't really many ways to ease the transitions, its mainly a case of getting your head down and changing those pages.

AJAX implementation for ASP and ASP.NET hybrid

A little setup:
Our shop has a mixture of different platforms. Almost all of our web development is done in classic ASP. We have a WinForms application in development that is being written using the .NET 3.5 framework.
The problem:
I am writing a webservice for updating information to this enterprise application. Most of the classes and business logic also pertain to the WinForm application. On top of this, there needs to be a way to maintain some data on a website. Because we use classic ASP, I have decided upon using a generic HTTPHandler to make posts to. I use an ASMX webservice to query since I get XMLSerialization for free. However, I know this is not the normal use of a Handler and can't help but think there is a much better, short of converting a bunch of stuff over. Doing just this much is quite a bit more work than the project timelines allow. Can anyone offer some insight on this topic? More generally, how have people converted from classic ASP to ASP.NET? We are not a very large shop, so I think we're going to have to take it incrementally.
As a follow up to this question, I am finished with the roll out of this project and it is working pretty well. The AJAX portion was pretty easy doing it this way. However I never got ternary operators to work in my handler page and I'm not sure why. This resulted in first checking the HTTPContext to see if the control I was trying to read was actually there, and if it was, taking in the value from it. I suspect I did something wrong but for now I'll have to move on and refactor later.

Resources