问题服务器端包含 [英] Problems with Server-side Includes

查看:122
本文介绍了问题服务器端包含的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我拼命想使用服务器端包含在一个项目我工作,因为我只是有一些HTML的重复,我需要得到它的几页。 必须我用ASCX或其他一些包括技术... 我的意思是,会如果我使用服务器端包含雷击?

I desperately want to use server-side includes in a project I'm working on because I just have some HTML that repeats and I need to get it on several pages. Must I use ascx or some other include technology... I mean, will lightning strike if I use server-side includes?

我的客户 - 中产人士 - 说做最简单的方法,这很可能会在不久的CMS反正重做。我不能使用服务器端包含?

My client -- the middle-person -- says "do what's easiest, this will probably be redone in a CMS soon anyway." Can I not use server-side includes?

这是ASP.NET 2.0。

It's ASP.NET 2.0.

注意:我觉得这已经被问过,但我无法找到它。如果有,请让我知道,我会亲自删除,谢谢!

Note: I feel this has been asked before, but I couldn't find it. If it has, please let me know and I will personally delete it, thanks!

编辑:什么办法让一个包括一行将被罚款和我在一起,如果您有任何建议

Any way to get an include ON ONE LINE would be fine with me, if you have suggestions.

编辑:为什么我喜欢包括

包含code:

!--#include file="inc_footer.aspx"-->

在同一code的控制。首先,你需要其中的一个

the same code for a control. First you need one of these

<%@ Register TagPrefix="a" TagName="HeyFooter" Src="inc_footer.ascx" %>

然后就可以使用它像这样

and then you can use it like this

<a:HeyFooter runat="server" />

这是一种长的时间我需要什么。

this is kind of long for what I need.

注意两个安全与包括考虑:1)不要使用。公司扩展,因为它可以浏览。 2)不包括文件名,根据用户的变量,最好的答案要点ØUT。

Note Two security concerns with includes: 1) don't use the .inc extension, since it can be browsed. 2) do not include filenames based on user variables, as the best answer points o ut.

推荐答案

如果您包括通过一个字符串变量的文件:<!code>&LT; - #include文件= some_variable - &GT; ,则根据该变量的填充方式有可能的攻击黑客可以做,包括他自己的文件和你的机器上运行任意code。但只要你使用一个字符串,你就不会遇到这个问题。

If you include a file via a string variable: <!--#include file=some_variable -->, then depending on how that variable is filled there are possible attacks a hacker could do to include his own files and run arbitrary code on your machine. But as long as you use a string literal, you won't run into this problem.

我会用母版页在ASP.NET中。这是有一个网页的公共区域的接受的方法。

I would use Master Pages in ASP.NET. This is the accepted way to have common areas of a page.

您同样也会创建一个母版页,你会经常页面,则其他每个页面的修改将是最小的。一行添加到每个页面文件的顶部,然后指定所使用的部分。

You would create a Master Page similarly as you would regular pages, then modification of each of the other pages would be minimal. Add a single line to the top of each page file, then specify the sections used.

这篇关于问题服务器端包含的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆