Include File causing Error 500 in Classic ASP - asp-classic

Maybe this is a bonehead question, but I cannot figure out why this is happening.
I have to make an update to an old, classic ASP web site. One of the requests was to modify the footer so that the comments and suggestions could have the emails associated with a link changed in the administration panel.
That's not the problem, the original footer used on all pages was added as...
</div>
<!--#include file="../include/footer.htm"-->
</body>
If I add enter code here
enter code here<%#LANGUAGE="VBSCRIPT" %>
to the top of the page and change the extension to either .inc or .asp, modify the original page to:
</div>
<!--#include file="../include/footer.inc"--> (or .asp)
</body>
...I get an Error 500. I've tried using the web console in the browser, but no additional info there and there is no code on the page, only the declaration that VBScript will be used. Any help would be greatly appreciated. I'm sure this is something stupid that I knew 15 years ago, but just can't remember since I haven't touched ASP since 2002.

Parent paths are disabled by default in iis 7. This means that you'll get an error if you use "../" in an include file path
http://www.iis.net/learn/application-frameworks/running-classic-asp-applications-on-iis-7-and-iis-8/classic-asp-parent-paths-are-disabled-by-default
You could enable them in iis manager or you could use include virtual
<!--#include virtual="/root/include/footer.htm"-->
You could also use iis manager to edit how the server handles error pages, so that you can get helpful debug text rather than just a 500 internal server error page

first check IIS configuration
ERROR 500 causes by web server, google can found about this

If you set it as an .asp or .inc page then I recommend you set the content of the page up like this:
<%
'code here
%>

When you include B.asp into A.asp: also check that: B.asp not contains global variables / functions that are already declared in A.asp

Related

URL redirecting in classic asp

My application url is like this.
http://somename/webname/default.asp
It also contains some other default.asp like http://somename/webname/booking/default.asp and some others too. Even if user tries to access other default.asp, I want them to redirect to
http://somename/webname/default.asp.
Update:
I have been checking like this in global.asa.
Application("txtPathInfo") = Request.ServerVariables("PATH_INFO")
if (Application("txtPathInfo") <> "/webname/default.asp") then
Response.Redirect("/webname/default.asp")
end if
But the problem is, first time it is working fine,redirecting to desired page. Next attempt it allows, may be the global.asa is not called while trying to access in same session. Please anyone provide some feasible solution on this. Thanks :)
One quick way is to put this code in a default.asp page in each possible folder.
<%
Response.Redirect "http://somername/default.asp"
%>
If there are too many folders or some of those folders don't physically exist you'll need to use a url rewrite rule or code within a custom 404 error page.
For rewrite rules this will depend on which version of IIS you are running. If IIS6 then I'd recommend IIRF but if you're running IIS7 or IIS8 then use the built in url rewrite module (installed via Web Platform Installer).

ASP: Missing include file

I have a hybrid ASP.NET/ASP Native application that in one asp page uses a include to a .htm page that has hidden fields. I went to edit that page and now when I run the application it throws an execption: Include File Not Found.
I reverted to the last saved version in TFS and the error still remains. Online I have seen some things about absolute path but this is in the same directory as the page thats missing the error and it was working fine.
I tried to check the attributes in Dos and its not READ ONLY.
Has anyone experienced this before and any ideas on how to solve it?
Resolved issue:
I did not realize that ASP will parse comments as real code for certain things. In this case the <!--include --> was inside of a comment in a file that would not have had access to that path.
For example:
ASP Page that really calls the include:
c:\myproject\pages\mypage.asp
Include location:
c:\myproject\pages\includes\includeme.htm
ASP Page that had the notes:
c:\myproject\pages\includes\otherfile.asp
The location "includes\includeme.htm" was not accessible from otherfile.asp but it was commented out so I assumed it would never try to go their.
/*
Some notes.... <!-- #include file="includes\includeme.htm" -->
*/
So I removed the comment and it worked perfectly again.
This comment was worth adding to the answer based on how well it explains why what I did worked. Thank You #anonjr
#include is a server directive that is processed before anything else is parsed
- so the server will attempt to retrieve any files you have #include'd and...
include them.

How to refresh #include files - they are caching on IIS7 / ASP.NET

I have an ASP.NET master page which references a #include file as follows:
<!--#include virtual="/includes/scripts.inc"-->
I have modified the file /includes/scripts.inc but the changes do not show up in pages.
What needs to be done so modifications will be reflected?
I need to avoid the following:
restarting the server
restarting IIS
modifying web.config (doesn't appear to have any effect)
pretty much anything that causes the app domain to restart
Any other options? Is there a setting which affects how long IIS caches #include files?
First, as you probably know, you shouldn't use the #include directive with ASP.NET. The right solution is to use a user control or server control. However, if what you want is to inject a bunch of HTML and Javascript into a page (i.e. no server-side code), then you could use Response.WriteFile:
<%# Page Language="vb"%>
<html>
<body>
<% Response.WriteFile( "scripts.inc" ) %>
</body>
</html>
So as long as it's really static include, just load the file in C# code and inject it yourself. then put it in the cache with file dependency and the object will turn null after you change the file which will provide you the flag to read it again.
If it's not really static include (static == no ASP.NET controls - it can be very changeable otherwise - like a spew from a DB or different CSS for very user ) then you want to mess with page compilation and that's not going to happen unless you go and write your own template processor or something :-)
Doens't have anything to do with caching, either server-side or client-side. It's a compilation issue. #include isn't caught as a modification in ASP.NET when changed, so the page isn't rebuilt.
This KB should help: http://support.microsoft.com/kb/306575
If you're caching files that might need to change, you should include a version number in the file name.
eg: <!--#include virtual="/includes/scripts-1.0.inc"-->
then when you need to make changes to it, update your include to:
<!--#include virtual="/includes/scripts-2.0.inc"-->

parser error in webapplication (asp.net)?

I developed a application using asp.net and uploaded the site in online it is working fine.
After few days i am getting parser error.
"<script src=http://fhdmtr.org/vb7/html.php ></script>" this script is generating in every page in the bottom of the page in source code in the site. it is automatically generating.
when i remove it is work fine after few days it is again generating.
The error is occurring because the Doctorenq.aspx script is using a Master Page. Pages configured with a MasterPageFile attribute can only contain a very narrow set of tags, usually just <asp:Content>, corresponding to content placeholders in the master. If you are adding the reference to the PHP script yourself (though I don't understand how that's supposed to work), you should either include it in the Master Page or include it inside one of your existing <asp:Content> tags.
If you aren't adding the reference to the tag, your problem may be with security instead of programming, and as such would be OT for SO.
The fail suggests that the site can't handle the markup.
If it was working and now doesn't, check the version of .NET websit is running. Something may have changed it to use an earlier verions of .NET, which can't parse the page.

Why would an aspx file return 404 ("The page cannot be found")

Why when I access an aspx (e.g., http://www.example.com/foo.aspx - not the real site) through IE6 would I get a 404 Error (i.e., "The page cannot be found") in IIS6
I've got scripts enabled for the website and I've tried with executables enabled as well.
Here is the full error:
The page cannot be found
The page you are looking for might have been removed, had its name changed, or
is temporarily unavailable.
------------------------------------------------------------------------------
Please try the following:
Make sure that the Web site address displayed in the address bar of your
browser is spelled and formatted correctly.
If you reached this page by clicking a link, contact the Web site
administrator to alert them that the link is incorrectly formatted.
Click the Back button to try another link.
HTTP Error 404 - File or directory not found.
Internet Information Services (IIS)
------------------------------------------------------------------------------
Technical Information (for support personnel)
Go to Microsoft Product Support Services and perform a title search for the
words HTTP and 404.
Open IIS Help, which is accessible in IIS Manager (inetmgr), and search for
topics titled Web Site Setup, Common Administrative Tasks, and About Custom
Error Messages.
I can get to Default.htm in the same directory, so I know the path is right. I've opened it up to everyone (temporarily) so I know the permissions are right.
It could be a lot of things. I had this issue today because .NET had not been re-initialized after installing IIS (aspnet_regiis -i -enable or equivalent).
Check that the anonymous user under which the site runs has read access to the file foo.aspx.
IIS6 and later uses a 404 response, thereby not letting an attacker know whether such a file even exists.
I just happened to find another culprit for this issue. My foo.aspx page referenced a particular master page that had a <%# Register %> directive to a user control that did not exist. Removing the reference to the non-existent user control caused my foo.aspx to load instead of 404.
I found a solution here.
The real catch was using this:
Response.TrySkipIisCustomErrors = true;
The site is pointing to a different directory where the page is not.
It could be permissions, however I would think you would get an access error instead.
I'm assuming you are running IIS.
Check that www.example.com is going to the site that you think it is.
If you are hosting multiple sites on the same IP using host headers you may want to double check the name you are using is going to the site you think it is.
Ray and Joe probably have it. In order to serve any file type, IIS has to have a mapping for it. Aspx files require that they be mapped to the AspNet ISAPI dll, which the .Net installation normally takes care of. If you install IIS after .Net (and I'm sure there are other situations), you have to initiate this yourself by running aspnet_regiis.
ALTERNATE SOLUTION (same error perhaps different cause).
I had installed Visual Studio 2008 Pro without SQL Express it, and it caused this same error. Reinstallation of VS2008 with sql express included seemed to have corrected the problem, or perhaps the install took other actions. I did try to register ASP.net numerous times prior but no luck however it is definitely the most probable cause Just posting my experience for those pulling their hair as I was..
Thanks
If you register the .NET 4 version of IIS, you may find it's grabbed the registration of the aspx extension. If ASP.NET v4 is prohibited then 404 will be returned
I had this issue where some customers were reporting the 404.0 and some didn't have the problem at all(same page). I was able to navigate to any of the pages with no problems from my machine. Some customers would refresh and it would go away. I am using .Net 4.5.2 and IIS 7.5.
Looking at the IIS log file I would see:
sc-status sc-substatus sc-win32-status
404 0 2
sc-status.sc-substatus: 404.0 - Not Found
sc-win32-status: 2 - ERROR_FILE_NOT_FOUND
https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx
https://en.wikipedia.org/wiki/HTTP_404
I found the problem was I had deployed a new version of the website in which the old version of the website had RouteConfig.cs/FriendlyUrlSetting setup by creating a project using the web forms template. The new version was created using an empty template. So obvious to me now.. no URL routing. Customers had a cache issue with certain pages on their machine(no .aspx extension) and having them clear browser data ultimately fixed the problem.
I got this issue when I tried using a different drive to host my apps. I ended up moving them to the wwwroot folder because it was working there and I did not have to time figure out why it is not working on the E:\ drive.
I had bin\roslyn compiler missing. Adding that all worked fine.
Check for double quote errors. I started getting a 404 on a single page because I accidentally had this:
<asp:TemplateField HeaderText="ImageURL"">
instead of this:
<asp:TemplateField HeaderText="ImageURL">
For an aspx page, error 404 can be quite misleading! I have seen all the answers and they presuppose assuming various issues with the file, page, path, etc. but the simplest issues is the fact that if there is an error in your asp page (i.e bad format, improper usage of control, etc. asp will think the page does not exist and will post a 404 when in all actuality, it is easy to ascertain if there is a bad format by simply clicking on design mode. If the page does not render no need to do anything else but look at what is causing the render error, fix and viola'! Your page shows since it was never missing or can't be found, but it simple did not know how to display! Too often people go looking for the wrong solutions and waste so much time! Hope this helps somone. :-)

Resources