Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><a href="http://msdn.microsoft.com/en-us/library/system.web.httpresponse.writefile.aspx" rel="nofollow noreferrer"><code>Response.WriteFile</code></a> just writes the filecontents into the Http response stream, without parsing it.</p> <p>Although it is possible to use <a href="http://msdn.microsoft.com/en-us/library/3207d0e3%28v=vs.80%29.aspx" rel="nofollow noreferrer">Server Side includes in asp.net</a> (<code>&lt;!--#include file="xxx.ext" --&gt;</code>), this has an asp-classic code smell to it IMO.</p> <p>The better way to get re-use of <code>.aspx</code> components is by using a <a href="http://msdn.microsoft.com/en-us/library/26db8ysc(v=vs.85).aspx" rel="nofollow noreferrer">User Control (.ascx)</a>.</p> <p>Similar question <a href="https://stackoverflow.com/questions/11959125/asp-net-code-within-include-not-executing">here</a></p> <p><strong>Update</strong></p> <p><code>Response.WriteFile</code> is fine for plain Html, .css or .js, but not for code containing c# or referencing .Net objects (you've used <code>Session</code> in your code), e.g.</p> <pre><code>Response.WriteFile("HtmlSnippet.html") </code></pre> <p>where <code>HtmlSnippet.html</code> is </p> <pre><code>&lt;p&gt;In breaking news, scientists have discovered a planet in &lt;a href='http://en.wikipedia.org/wiki/Alpha_Centauri_Bb'&gt;Alpha Centauri&lt;/a&gt; &lt;/p&gt; </code></pre> <p>Using a Server Side Include, e.g. <code>&lt;!--#include file="file.inc" --&gt;</code> would allow you to do put something like this in file.inc:</p> <pre><code>&lt;% if (Session["desig"].ToString() == "Developer"){ %&gt; You are a Developer!! &lt;% } %&gt; </code></pre> <p>However, the recommendation is to use a User Control (<code>.ascx</code>), which allows you to do much the same as the server side include, but just in a much more reusable, object oriented, and testable fashion. Your reusable Control will be a first class object, with properties, methods and be able to raise events. You'll need to do some research here.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload