How to set Allow Parent Paths in IIS Express Config using asp directive - asp-classic

This is a continuation of a answered question in the following link:
How to set Allow Parent Paths in IIS Express Config
I am running a classic asp web site in IISexpress.
The same web site is also used in IIS 7.5 in a w7 pro and works fine enabling the parent paths in the IIS configuration of the web but trying to use the web.config in IISExpress does not work
The problem that I am experiencing is that in the suggested web.config in order to enable the parent paths:
<configuration>
<system.webServer>
<asp
enableParentPaths="true"
bufferingOn="true"
errorsToNTLog="true"
appAllowDebugging="true"
appAllowClientDebug="true"
scriptErrorSentToBrowser="true">
<session allowSessionState="true" />
<cache diskTemplateCacheDirectory="%TEMP%\iisexpress\ASP Compiled Templates" />
<limits />
</asp>
</system.webServer>
</configuration>
I get a 500 error every time that I try to use any asp tag
If I remove the asp tag it all works fine,
Anybody has a clue?
TIA

You have not read carefully. The configuration file that mentioned isn't web.config. It is applicationHost.config. As a shotcut:
Press Win+R
type
notepad "%userprofile%\Documents\IISExpress\config\applicationhost.config"
hit ⏎. This will open the host configuration file with notepad. You need to find your web site's section. It's something like <location path="YourSiteName"> ... </location>. Look inside that node, find the <asp> section and change with yours. Finally, don't forget to remove the asp section from web.config.

Related

404 Not Found aspx file but it is there

I´m using Plesk and in Web scripting and statistics I have Microsoft ASP support in ON.
I uploaded a application (which works correctly in my PC) to a directory and it can be shown but when I go to the aspx file it shows me the 404 error (The path is the correct).
I noticed that some files in "shtml" extension are neither shown by the server.
This is my very first time with ASP.NET, ISS8 and Plesk. I don´t know what to do. I will thank you for your help
You have to set the HTTP Handler Extension. If you have no access to IIS directly, you could do on the web.config:
Open the Web.config file for the application, locate the httpHandlers element of the system.web section and add an entry for the file-name extension
Example:
<system.webServer>
<handlers>
<add name="SampleHandler" verb="*"
path="SampleHandler.new"
type="SampleHandler, SampleHandlerAssembly"
resourceType="Unspecified" />
</handlers>
</system.webServer>
For more configuration options please refer to:
https://msdn.microsoft.com/en-us/library/bb515343.aspx
and
https://msdn.microsoft.com/en-us/library/46c5ddfy(v=vs.100).aspx
Check also the Custom Handler Policy of Plesk that should not be enabled:
https://docs.plesk.com/en-US/onyx/administrator-guide/plesk-administration/securing-plesk/custom-handlers-policy.76787/
Here I've found also another interesting document:
https://learn.microsoft.com/en-us/iis/configuration/system.webserver/handlers/
Scroll down and you'll find a piece of code to add the handlers programmatically, even if I suggest you to add them in your web.config

I want to url redired in asp.net using web.config

I have one or more than one url like http://vfiresolution.in/pdf/p.pdf. And I want to redirect the above url to http://vfiresolution.in/page.aspx?id=1.
I am using the below given code. My code is working on local host. But If i publish my code on shared server code not working.
my code is
<configuration>
<location path="pdf/p.pdf">
<system.webServer>
<httpRedirect enabled="true" destination="http://vfiresolution.in/page.aspx?id=1" httpResponseStatus="Permanent" />
</system.webServer>
</location>
</configuration>
http://www.iis.net/configreference/system.webserver/httpredirect
check the iis
(httpredirect)
Compatibility
The httpRedirect section of web.config is compatible with IIS 7 (w2k8) and IIS 7.5 (w2k8 r2).
Web.config files are deeply integrated with IIS 7.x.
The httpRedirect directives listed will apply to all files and directories (php, jpg, png, htm, etc), not just asp.net files.
While some web.config sections sometimes require that the containing directory is set as an application, this isn't one of them.
A simple web.config with a httpRedirect section may be placed in any directory, and the directory does NOT need to be set as an application.

Migrate ASP from root to subdirectory

I'm in the process of converting an existing ASP website into PHP while retaining the ASP website as an older version. Since I'm not an ASP developer, I thought it would be simple as moving the contents of the root directory into its own directory that I've labeled as v1.0 so that the ASP version can be viewed by going to www.mysite.com/v1.0 while the new PHP version (v2.0) can be viewed by going to www.mysite.com
Herein lies the problem. Doing this causes flags all kinds of errors (all related to "Server Error in '/' Application. Runtime errors"). The best I can figure out is that the web.config file needs to be tweaked in the v2.0 directory. Can any of you ASP experts recommend a simple solution to make this happen? I would like to have an empty root directory if possible since the new v2.0 version will be in all PHP and want to "self contain" the ASP version within the v1.0 directory as much as possible.
Thanks!
After a bit of wrangling, finally figured out that I needed to set up v1.0 as its own application under the IIS control panel. Once that was done, then all the contents of the root directory could be moved over to the v1.0 sub-directory and viewed via www.mysite.com/v1.0 -- thanks to Sean! for his help!
Most Classic ASP pages use Server Side Includes, if the site is using a SSI such as:
<!-- #include virtual = "include-file.inc" -->
, then you will need to change all of these to be
<!-- #include virtual = "v1.0/include-file.inc" -->.
I assume that you are using IIS 7 or IIS 7.5, since you are not seeing the actual error, you will need to modify your web.config file.
<configuration>
<system.webServer>
<asp scriptErrorSentToBrowser="true" />
<httpErrors errorMode="Detailed">
</system.webServer>
</configuration>
Reference:
http://learn.iis.net/page.aspx/564/classic-asp-script-error-messages-no-longer-shown-in-web-browser-by-default/
Update
Since it now sounds like you are using ASP.NET, you would need to change your web.config as below to see the full error:
<configuration>
<system.web>
<customErrors mode="Off" />
</system.web>
</configuration>

Deny access to a folder in ASP.NET

is it possible to prevent browsing of a folder contents in an ASP.NET web application other than creating a default page, say using web.config?
I would like to avoid using IIS for this if possible.
Thanks
If you are using IIS7, you can use web.config files for this. Specify a <location> tag for the desired folder, and give it a <directoryBrowse> sub-tag, ie:
<location path="path to your folder">
<system.webServer>
<directoryBrowse enabled="false" />
</system.webServer>
</location>
The previous answer system.webServer -> directoryBrowse is new and can be used when your site is running under IIS7 (be it debugging or otherwise) only, it will not work in IIS6. In IIS6 you need to do it using the IIS management console.

IIS7: disabling HttpModule in subapplication - sites, application and virtual directories

I have a few aspx files in a "Cache" folder in my application and I do not want HttpModules to run for those files in that folder. I tried having a web.config in subdirectory but learned that HttpModules take the root web.config and not that of the subdirectory.
Reference 1, Reference2. So I decided to have this directory as a sub application as per suggestion here and here.
So I configure my application,then "add application" , map it to this directory, which already was inside this application and boom, it fails. It works for a static html file, but aspx files are not available.
My question is, how do I configure a sub-application in IIS7 so that the sub-application can have its own web.config and there I can disable HTTPModules of the root application
Edit:In fact I tried creating a subapplication within my main application and it did not work. Can some one point me to any article on how to configure a sub-application in IIS7 ?
Edit2: adding the error image. So how should I configure the child app pool. The child app runs in the same app pool as that of parent
Edit3: sorry, the child was running on a different app pool. A generic app worked(without modules). I am marking the answer after I try out the modules.Thanks for your help guys. There is something specific in my parent app web.config, which I am going to hunt down now.
EDIT: Actually both the answers provided below are correct. If you are using IIS7 integrated mode your modules should be in system.webServer and if IIS7 - classic mode your modules (and handlers?) should be in system.web
JKG has the right answer for IIS6, but the syntax is a little different in IIS7:
<system.webServer>
<modules>
<remove name="MyModule"/>
</modules>
</system.webServer>
The web.config will always inherit from its parent if it's in the same web application but you can clear the entire thing or remove an item like so:
From the child web.config (clear all or remove an item)
<httpModules>
<clear />
<remove name="MyModule"/>
</httpModules>
From the parent config by using the location tag...
<location inheritInChildApplications="false">
<system.web>
<!-- ... -->
</system.web>
</location>
http://www.jaylee.org/post/2008/03/Prevent-ASPNET-webconfig-inheritance-and-inheritInChildApplications-attribute.aspx

Resources