Static html files to aspx RRS feed

  • Question

  • User694418659 posted

    Hello all,

    We have inherited a site of around 10 000 html pages. The files are mostly text reference articles and have been cited by many hundreds of times in various professional journals. We're therefore very concerned about having to change all our file extensions to apsx. Is it somehow possible to migrate the entire site to .Net and keep the html file extensions intact, or another way of being able to integrate these html files without having to alter their file extension.



    Thursday, March 15, 2018 12:54 PM

All replies

  • User475983607 posted

    There is no reason to change the file extension to aspx unless you want to generate dynamic HTML.

    Can you explain the problem you are having?

    Thursday, March 15, 2018 1:07 PM
  • User694418659 posted

    Thanks. We're not having any problems as such, but we were wanting to make use of some .Net functionality eg. Master pages. It is my understanding that MP will only work with files with aspx extensions. But I'm largely ignorant about this, so quite likely wrong.


    Thursday, March 15, 2018 1:14 PM
  • User475983607 posted

    Thanks. We're not having any problems as such, but we were wanting to make use of some .Net functionality eg. Master pages. It is my understanding that MP will only work with files with aspx extensions. But I'm largely ignorant about this, so quite likely wrong.


    Correct, ASPX content pages are required to take advantage of Master Pages.

    You still have not answered the question of "What problem(s) are you trying to solve?".  

    IMHO, converting 10,000 static HTML pages to ASPX to take advantage of master pages is not a good reason to convert.   Maybe you can leave the html pages as is and add new features using ASPX or better yet move to MVC.   I assume the HTML pages use a layout template and navigation of some sort.  Regardless of the technology change you still need to remove/modify layout and elements.  Correct?

    If the HTML pages are fairly plain then you can look into URL rewriting or an HTTP Handler to invoke an HTML page loader.  Basically invoke a base ASPX content page that loads the  requested HTML file.  How easy this is depends on how the current site is designed.

    Thursday, March 15, 2018 2:07 PM
  • User694418659 posted

    The site was built using Microsoft Expression Web and makes liberal use of Dynamic Web Templates (DWT). Site navigation is entirely tied into these templates. Indeed, we would have to site-wide changes, but uncoupling pages from DWTs is not a challenge. I have attached a sample page.

    <!DOCTYPE html>
    <!-- #BeginTemplate "../templates/today-template.dwt" -->
    <meta charset="UTF-8" />
    <meta content="width=device-width, initial-scale=1.0" name="viewport" />
    <!-- #BeginEditable "doctitle" -->
    <title>CYC-Net: Stories of Children and Youth</title>
    <!-- #EndEditable -->
    <!-- Google Tag Manager -->
    new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
    <!-- End Google Tag Manager -->
    <meta content="CYC-Net" name="description" />
    <link href="../cssx/cycnet.css" rel="stylesheet" type="text/css" />
    <link href="http://fonts.googleapis.com/css?family=Roboto+Condensed:300italic,400italic,700italic,400,300,700" rel="stylesheet" type="text/css" />
    <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
    <script src="https://s3.amazonaws.com/menumaker/menumaker.min.js" type="text/javascript"></script>
    <script src="../script.js"></script>
    <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet" />
    <link href="../cssx/styles.css" rel="stylesheet" type="text/css" />
    <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
      (adsbygoogle = window.adsbygoogle || []).push({
        google_ad_client: "ca-pub-4642713783989806",
        enable_page_level_ads: true
    <!-- Google Tag Manager (noscript) --><noscript>
    <iframe height="0" src="https://www.googletagmanager.com/ns.html?id=GTM-59F7HC9" style="display: none; visibility: hidden" width="0">
    <!-- End Google Tag Manager (noscript) -->
    <div class="bannerholder">
    	<iframe allowtransparency="true" frameborder="0" height="90" scrolling="no" seamless="seamless" src="http://cdn.bannersnack.com/iframe/rotator.html?hash=0ae7cc1a83538cfbd61d94fcr1409314&amp;t=1474466434&amp;env=live&amp;wmode=opaque" width="728">
    <!--webbot bot="Include" tag="BODY" u-include="../topbar-include.html" --><div id="topbarholder2">
    	<div class="row">
    		<div class="col-9">	<h2>Today</h2>
    	<p class="sectioncaption">Stories of Children and Youth</p>
    		<div class="col-3 right">
    			<div id="google_translate_element"><span class="small">Translate this page
    			<script type="text/javascript">
    function googleTranslateElementInit() {
      new google.translate.TranslateElement({pageLanguage: 'en', layout: google.translate.TranslateElement.FloatPosition.TOP_LEFT, gaTrack: true, gaId: 'UA-6475030-1'}, 'google_translate_element');
    			<script src="http://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit" type="text/javascript"></script>
    <!-- #BeginEditable "Text%20entry%20area" -->
    <div id="blanksheet">
    		<p><em>Click the article title to be taken to the full story.</em>&nbsp;</p>
    		<a href="https://www.advocate.com/commentary/2018/3/12/extending-lifeline-homeless-lgbt-young-adults">
    		Extending a lifeline to homeless LGBT young adults</a></h3>
    		<p>On March 7, the New York City Council approved a package of bills 
    		that would extend access to youth services and shelter to homeless young 
    		adults, many of whom identify as LGBT. If Mayor de Blasio signs the 
    		bills into law, New York City can set an example for cities across the 
    		U.S. trying to patch up the cracks that homeless and runaway youth fall 
    		into on the road to independent adulthood. </p>
    		<p>Studies have consistently shown that LGBT youth are at a heightened 
    		risk of homelessness, in large part because their families have rejected 
    		them because of their sexual orientation or gender identity. In surveys, 
    		as many as 40 percent of runaway and homeless youth identify as LGBT.
    		<p>In early adulthood, something as simple as shelter can be 
    		life-altering. Marcelle, a gay 21-year-old, pointed out that raising the 
    		age for services “would open so many doors – I could finish school 
    		instead of urgently looking for housing, which is what I’m doing now. 
    		It’s hard to finish the semester and look for housing, and to manage all 
    		of it.”</p>
    		<p>Recognizing this unique vulnerability, LGBT advocates, community 
    		centers, and service providers across the U.S. have mobilized to expand 
    		LGBT-inclusive youth services. But many of these services end when young 
    		people turn 18 or 21, cutting them off from services before they’re 
    		equipped with the employment, housing, and financial stability to make 
    		it on their own. </p>
    		<p>This winter, I spoke with homeless young adults in New York City who 
    		have aged out of youth services and found themselves suddenly cut off 
    		from crucial sources of support. They identified a wide range of 
    		services – counseling, job training, internships, health care, sexuality 
    		education, and many others – that they’d been able to get through youth 
    		programs but were now unable to find. </p>
    		<p>Under the current law, New York City government funding can only be 
    		used to provide support services for young people until they turn 21. 
    		But few young adults are fully independent at that age, especially if 
    		they have experienced homelessness. Maddox, a 21-year-old, told me, “We 
    		have to deal with so much stuff, we didn’t have time to do things 
    		teenagers normally do.”</p>
    		<p>When young people don’t have financial literacy, a chance to build 
    		savings, or a steady job, it becomes difficult for them to find and keep 
    		permanent housing. In the current system, Maddox said, “it seems like 
    		they just want you to go from being a young homeless person to an older 
    		homeless person.”</p>
    		<p>Even for youth who do not age out of services, support can be 
    		limited. New York law allows youth to stay in crisis programs for up to 
    		60 days and transitional independent living programs for up to 18 
    		months. In many cases, that isn’t long enough for homeless LGBT youth to 
    		make a plan and find alternatives. </p>
    		<p>Lex, a 24-year-old transgender man, was forced to leave home when he 
    		began to act more masculine and his mother reacted with physical 
    		violence. As he explained to me, adjusting to those circumstances can 
    		take time. “Your family kicks you out, and all of a sudden, you only 
    		have six months to get to where you need to be, you’re just getting into 
    		emergency housing. It’s no time, really, to get acclimated.”</p>
    		<p>The consequences of being cut off can be devastating. Kay, a 
    		24-year-old, told me a particularly painful story of a friend who aged 
    		out of services last summer and had no place to go: “She had been with 
    		her program long enough that she was getting stuff done, but she wasn’t 
    		where she needed to be. And they abandoned her, the day before her 
    		birthday. Nobody checked up on her, nobody asked how she was doing.” 
    		Shortly after aging out of her housing, her friend was shot and killed 
    		on the street.</p>
    		<p>Under the leadership of Corey Johnson, the New York City Council 
    		speaker, the council approved a set of bills that address these issues 
    		head on. One would allow city funding to be used to serve young people 
    		up to age 25. Another would extend the length of time that young people 
    		can stay in crisis programs and transitional independent living 
    		programs. In addition to expanding services, a third would require the 
    		city to create a system that will meet the needs of all homeless young 
    		<p>These changes would benefit homeless young adults generally, but 
    		they’re particularly important for those who identify as LGBT. Youth I 
    		spoke with emphasized the stark difference between services that were 
    		tailored for youth and adult shelters. Unlike LGBT-specific youth 
    		resources like the Ali Forney Center here, many adult shelters serve a 
    		general population. The young adults I interviewed described being 
    		misgendered, harassed, and fearing physical and sexual assault from 
    		residents who were often decades older than they are.</p>
    		<p>Mayor de Blasio can make a huge difference for the youth of New York, 
    		and in particular for LGBT young people, by signing the youth services 
    		bills into law. Leadership on this issue would encourage cities across 
    		the country to take stock of the services they provide and see whether 
    		they are doing enough to serve homeless young adults. For these young 
    		people who face so many challenges, these services can make the 
    		difference between falling back into homelessness and becoming an 
    		independent adult.<br><br>By Ryan Thoreson</p>
    		<p>12 March 2018&nbsp;&nbsp;</p>
    		<p><a href="today180312.html">PREVIOUS STORY</a></p>
    <!-- #EndEditable -->
    <div id="footerholder">
    	<!--webbot bot="Include" tag="BODY" u-include="../bottombar-include.html" --></div>
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      ga('create', 'UA-6475030-1', 'auto');
      ga('send', 'pageview');
    <!-- AddThis Smart Layers BEGIN -->
    <!-- Go to http://www.addthis.com/get/smart-layers to customize -->
    <script src="http://s7.addthis.com/js/300/addthis_widget.js#pubid=ra-4e37b0715adf881c" type="text/javascript"></script>
    <script type="text/javascript">
        'theme' : 'dark',
        'share' : {
          'position' : 'left',
          'numPreferredServices' : 6
        'follow' : {
          'services' : [
            {'service': 'twitter', 'id': 'cycareworkers'}
    <!-- AddThis Smart Layers END -->
    <!-- #EndTemplate -->

    Might be we just leave it as is as we have no experience of MVC, but HTTP Handlers.


    Friday, March 16, 2018 7:09 AM
  • User753101303 posted


    Done from scratch it would be done by just having a couple of ASPX pages just fetching and showing any of those stories which would be considered as being "data" (even if it comes from a file with just the story rather than from a database).

    Do you keep adding new stories ? Do you plan a site layout change ? IMO don't do just an immediate technical change without having non technical objectives on this kind of massive change

    Friday, March 16, 2018 8:16 AM
  • User694418659 posted

    If it's not too much hassle, can you give me an example of how an aspx page would fetch an html page? Thanks,

    Yes, the html pages are added to constantly. No layout changes planned for the foreseeable future.


    Friday, March 16, 2018 8:41 AM
  • User475983607 posted

    If all the pages look just like the posted HTML, I would build a code generator to parse the HTML file and create ASPX pages; markup, code behind, and designer.   The concept is pretty basic.  Read the HTML grab the blanksheet section and use it to build the markup file.  The other two file will all be very similar except for the file names and namespaces etc.

    Depending on your experience this might sound complex but it's not.  It is very straight forward step by step file and string manipulation.  Once you get one file working, then you're good to go.  Craft a test project and manual convert one file which will become a template.

    Friday, March 16, 2018 11:05 AM
  • User694418659 posted


    Friday, March 16, 2018 11:18 AM
  • User753101303 posted

    You could use https://msdn.microsoft.com/en-us/library/system.io.file.readalltext(v=vs.110).aspx and then you can use for example a "placeholder" to insert this HTML content.

    It would be an extra step but similar to what suggested by https://forums.asp.net/members/mgebhard.aspx. It's likely a bit more difficult as it seems you also have some small parts  (title, category ) that are tied to a story especially as you are not familiar with development.

    And then when  you have something such as /mysite.com/story/today180312.html it would trigger a "story" page possible using a master page (ie you have just 2 ASPX pages) and it would fetch the relevant "180312" story to show that on the page. And so the same 2 ASPX pages could show any other story as well.

    Friday, March 16, 2018 1:12 PM