Take the 2-minute tour ×

I am working with a C# on visual studios.

What I would like to know is if it is possible to have a html template loaded from a directory on my computer. Then every time I load up my code it will load up the .html template automatically.

share|improve this question
Do you mean you'd like to create an aspx page? –  Jeff Watkins Jun 1 '12 at 21:32
A template .html for your web application projects? if that the case, you need to take a look to master pages: msdn.microsoft.com/en-us/library/wtxbf3hh.aspx. And if you need to add an specif html code to all your code you need to see to how to create a project template for visual studio msdn.microsoft.com/en-us/library/6db0hwky(v=vs.80).aspx –  Jorge Jun 1 '12 at 21:45

1 Answer 1

up vote 0 down vote accepted

Yes there is a way, not suggested but exist. You can use this code to include the file, inside your asp.net page.

<!--#include file="template.htm"--> 

What is dose is that is load this htm file and show it on the place that you have place this declaration. Also you must know that this file can not contain anything dynamically. This is a command code that comes from the old asp script code, and still work on asp.net

So I can not call it as template. If you wish to make something like a real template you must use a master page. Using a master page is far better, and you just copy paste your htm code inside the master page and there you have it.

relative: http://triaslama.wordpress.com/2008/11/19/how-to-include-file-in-aspnet-pages/

share|improve this answer
thanks this actually is the answer I was looking for, is there a way I can call the <!--#include file="template.htm"--> from a web.config so I don't have to put that code into the .aspx page? –  timisu Jun 2 '12 at 0:43
@timisu there is one different way to include other configs, on web.config. –  Aristos Jun 2 '12 at 7:49

Your Answer


