在包括不执行ASP.net code [英] ASP.net code within include not executing
问题描述
它一直以来我涉足服务器端的很长一段时间,但在我看来,嵌入到包括code文件脚本应该执行正常。这似乎并不是由于某些原因的情况。
It's been a long time since I dabbled server-side, but it seems to me that scripts embedded in an included code file should execute as normal. This doesn't seem to be the case for some reason.
的(Note--下面的显然是基于我在调试尝试简化的实现。我其实还有其他包括与该渲染就好了实际项目平HTML和JavaScript。这只是ASP code,它没有被正确解析,<%%>标签和所有)的
INDEX code
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My Site</title>
</head>
<body>
<% Response.WriteFile ("includes/test.aspx") %>
</body>
</html>
包含code
<% response.write("boo"); %>
该页面,从服务器中运行时,包括文件就好了......但脚本呈现为文本。
The resulting page, when run from a server, includes the file just fine... but the script is rendered as text.
我在哪里出了错?这里
非常感谢您的帮助。
推荐答案
没有什么会错了。
在 WriteFile的
,该文件的内容将被渲染。
When you WriteFile
, the contents of the file is going to be rendered.
ASP.NET不具有断绝侧的设施包括方式传统的ASP确实
ASP.NET doesn't have a facility for sever side includes the way classic ASP did.
您需要使用控件来动态建立一个网页,虽然你可能想看看 ASP.NET/MVC 而不是WebForms的,因为它是更接近你将如何做的事情与传统的ASP。
You need to use controls to build up a page dynamically, though you may want to look at ASP.NET/MVC instead of WebForms, as it is closer to how you would have done things with classic ASP.
这篇关于在包括不执行ASP.net code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!