how can I output the entire website as "static" files (ie. html, css, img) - asp.net

I have a dev site in MVC but wish to render the "pages" and corresponding "assets" (js, css, images, etc) to what one might call a "static site".
In other words, I don't want to deploy to an IIS server that supports MVC. I simply want to build the site in MVC then somehow parse those pages into static html/css/etc files and upload the site to a regular LAMP host.
Is there an easy way to automate this? NuGet package? Binary? MVC extension like maybe a handler add-on that can render out the static site in a single pass?
Are there "plugin" type of tools for this before the site is published to a public url?

If you use tools like HTTrack to download a complete website as static HTML page with all resources (CSS, Images & javaScripts etc) onto a folder. There are many such free or paid tools available over the internet.

Related

How to host GitHub repo on Nimbella

How can I host my github repo on Nimbella .
I have created a website using HTML,CSS,JS. which I have hosted on GitHub pages. but I want to host it on Nimbella.
https://nimbella.io/downloads/nim/nim.html#adding-static-web-content
Adding static web content
To add static web content to a project, add a directory called web as a peer of the directory called packages. This directory should contain files whose suffixes imply well-known mime types for web content, such as .html, .css, or .js.
Note: JavaScript files in static web content are not actions but are scripts intended to run in the browser.
The web directory can have subdirectories and can be built by website builders or other tools.
Like an action directory, the web directory may contain .include or .ignore to control what is actually considered web content, as opposed to build support or intermediate results. For more information about .include and .ignore, see Multifile actions created with autozip.
The web directory also supports integrated building, just like an action directory.
Here’s an example of a project with modest web content, populated by hand. For simplicity, the actions of the project are not shown.
example3/web/chatroom.html
example3/web/chatroom.css
example3/web/runner.js
example3/web/favicon.ico

How to use Windows Azure CDN with existing ASP.NET webforms application?

I have an ASP.NET Web Application on Azure and want to move my static content - images, CSS to the Azure CDN.
I have over 100 image files being used throughout the application stored in a folder "App_Themes/img" ...
In what way, can I minimize the effort in the move?
My current steps would be ...
- Manually upload all files to cdn ..
- Manually change all urls to the cdn (using Ctrl-H, but still is time-intensive and not error free)
- Somehow manage the testing locally... (Add some code at every page to use a baseurl, depending on debug or release) ...
Is there any way that I could add a new route, etc so that I don't have to manually change the urls, as well as move between file-system urls and CDN to develop the application locally and deploy it.
Thanks a lot ..
I think you can do this via IIS URL rewriting or move static content into a /cdn folder, I haven't tested this but Maarten Balliauw has a great blog post on how serve content from the CDN. "Using the Windows Azure Content Delivery Network"
What I did was added a config entry in the web.config:
and replaced path /App_Themes/SpringDoctor/images/ with <%=System.Configuration.ConfigurationManager.AppSettings["ImagesPath"]%>
And upload all images to the appropriate blob.

asp.net (web spider)

i wan to create a web spider that able to get some useful information from the other web site.
how can i get the file from the website and store into my server??
eg :
the url of the file is http://www.abc.com/attachment.php?aid=abc
how can i let the users of my website download the file without display the page http://www.abc.com/attachment.php?aid=abc ??
There are many ways to go about it.
The WebClient class can be used to fetch web resources, such as web pages.
If you want to crawl a site you will also need to parse the content in order to follow links and download the images and other resources (CSS, Javascript etc...) - I suggest using a parser like the HTML Agility Pack for parsing HTML so you can query it for these resources (that you may also want to download with WebClient).

How does people make ASP.NET page in URL with html file name?

I seen an ASP.NET application, in the URL is saying:
http://xxxxxxxxx/FILENAME.html?xxxx=xxx
How come it is html file? But not aspx file? How did they do it?
I heard from my manager that's an ASP.NET project he outsourced.
Sometime I seen people with their web page is ended in .html too, but obviously that is generated dynamically...
Files ending with .html are optional. These are static HTML-pages without any code-behind and can be included as part of any web application. They are not parsed and compiled by the server but rather just sent as good old predefined HTML.
You can also configure the web server so that it routes requests with different endings through the ASP.net rendering engine. This way you can keep the widely recognized ending .html and still have dynamic page generation.
The file extension is not necessarily tied to the execution engine. You can make ASP.NET process .aspx, .html, .htm, .bob, .foobar, .css, etc.
There are multiple of ways to do this:
In IIS manager, set the file extension mapping for .html to point to ASP.NET. If you're using MVC, you can handle this via routing.
Use a rewrite engine to map anything with a .htm* extension to .aspx
There are probably other ways, but these are the most direct.
Also, the .html extension doesn't mean that the file was dynamically generated.
You can use URL rewriting. There are a lot of different rewriters most popular being the URL rewrite module ( http://www.iis.net/download/urlrewrite ) and the built in (in ASP.NET 4.0) Routing Engine ( http://msdn.microsoft.com/en-us/library/cc668201.aspx ).
The URL Rewrite module is external to your application and it translates incoming URLs to regular .aspx URLs. You are responsible for generating the links with .html. It is good if you are adding it to an existing application.
The built in routing can generate urls based on routes and is configured in Global.asax (usually) with code.
Right click on the project.
Add new...
pick the HTML file type.
Some people prefer to use a different extension (or even none at all) in order to hide the technology used to develop the site.
Bear in mind that you would have to properly configure IIS to let the .net engine handle the .html file types.

asp.net static content in separate project. now how to refer?

Project1.csproj is the website project and StaticContent.csproj is the static content project to hold all .css, .js and image files. I am keeping it separate so that designers can work without touching the main project file and may be use cdn in future. But the problem is how do my .ascx and .aspx pages will refer to these css and js files as that when I run in localhost, it still picks up.
I think the best way is you create a website in IIS for the Static project, and reference it trough something like static.myproject.com (having the appropiate setup) on the other one.
You can still use Webdevserver on Project1.
Is most like what you will have when deploy, and you can put the URL on web.config for easy change

Resources