Server side issues

I desperately want to use server components in a project that I'm working on, because I just have HTML code that repeats, and I need to get it on multiple pages. Required I use ascx or some other include technologies ... I mean, will there be a lightning strike if I use the server side?

My client - the average person - says: "Do what is easiest, it will probably be redone in the CMS soon." Can I use the server side?

This is ASP.NET 2.0.

Note: I feel that this was asked before, but I could not find it. If you have, let me know and I will personally delete it, thanks!

Edit: Any way to get ON ONE LINE turned on will be fine with me if you have any suggestions.

Edit: Why do I like to enable it?

Include code:

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

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

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

and then you can use it as follows

 <a:HeyFooter runat="server" /> 

it's a long time for what i need.

Note Two security concerns include: 1) do not use the .inc extension, as it can be viewed. 2) do not include file names based on user variables, as o ut's best answer points.

+4
source share
3 answers

If you include a file through a string variable: <!--#include file=some_variable --> , then depending on how this variable is populated, there may be attacks that a hacker can do to include his own files and run arbitrary code on your computer. But as long as you use a string literal, you will not run into this problem.

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

You would create the main page in the same way as regular pages, then changing each of the other pages would be minimal. Add one line at the top of each page file, then indicate the sections used.

+4
source

No, you definitely don't need to use fancy .NET web form methods to do this if you want to keep it simple. Just put this at the points where you want to insert:

 <!--#include virtual="../repeatStuff/fun.html" --> 

There will appear html. I gave the path one up and down another directory. It is the β€œeasiest”, but also has the power to be very simple. Please note that this will not appear in your visual designer. (I never use it.)

+2
source

I still use it every time for a while, exactly for the purpose you are describing.

You do not need to register a user control, because it is just plain HTML. And you do not need the main page, because it is really just a html fragment that should be on several selected pages.

So, I have these words from the glossary of help text files:

 <!--#include file="~/Glossary/BusinessDetails.inc"--> 

In my opinion, there is nothing wrong with using the old school, including files for this purpose.

+1
source

Source: https://habr.com/ru/post/1299771/


All Articles