Response.WriteFile
just writes files to the Http response stream without parsing it.
While it is possible to use "Server side" includes in asp.net ( <!--#include file="xxx.ext" -->
), it has the smell of classic asp code to it IMO.
The best way to get component reuse .aspx
is with User Control (.ascx) .
Similar question here
Update
Response.WriteFile
great for simple Html, .css or .js, but not for code containing C # or .Net object references (you used Session
in your code) like
Response.WriteFile("HtmlSnippet.html")
where HtmlSnippet.html
is
<p>In breaking news, scientists have discovered a planet in
<a href='http://en.wikipedia.org/wiki/Alpha_Centauri_Bb'>Alpha Centauri</a>
</p>
Server side use Include, eg. <!--#include file="file.inc" -->
will allow you to do something like this in your .inc file:
<% if (Session["desig"].ToString() == "Developer"){ %>
You are a Developer!!
<% } %>
However, it is recommended that you use a custom control ( .ascx
), which allows you to do the same thing as the back end, but only in a much more reusable, object oriented, and testable way. Your reusable control will be a first class object with properties, methods, and the ability to raise events. You will need some research here.
StuartLC
source
to share