How do you allow parent paths in Visual Studio 201

2019-06-15 14:04发布

问题:

I've opened an existing web application project from Visual Studio 2013 (which runs just fine), in Visual Studio 2015. When I run it from within Visual Studio 2015 I get:

Active Server Pages error 'ASP 0131' 

Disallowed Parent Path 

/blah/login.asp, line 1 

The Include file '../includes/Security.asp' cannot contain '..' to indicate the parent directory. 

My IISExpress applicationhost.config file already contains the entry:

<asp appAllowClientDebug="false" appAllowDebugging="false" errorsToNTLog="false" enableParentPaths="true" scriptErrorSentToBrowser="true" bufferingOn="true">

            <session allowSessionState="true" />
            <cache diskTemplateCacheDirectory="%SystemDrive%\inetpub\temp\ASP Compiled Templates" />
            <limits maxRequestEntityAllowed="1073741824" />
        </asp>

My web application properties are set to use IISExpress.

What could I be missing?

回答1:

The 'applicationhost.config' has moved and is now located in the hidden .vs folder. Make sure you're updating the right file.



回答2:

Here is a much clear explaination although the accepted answer is in the right direction.

Since VS2015, IIS Express has changed where it picks up your applicationHost.config file. This is presumably to simplify the distribution of projects. It has moved away from the traditional C:\Users\<profile>\Documents\IISExpress\config\applicationhost.config folder (although this file will still exist on your computer to support older VS installations).

It is now located in the application project's root folder as a hidden file. To save you hunting for it, here is how you open it quickly and easily:

  1. Right click IIS Express from the tray icon and select Show All Applications.
  2. Click on the URL entry of your application. The "Path" and "Config" values then are shown as hypertext links further down in the IIS Express window.
  3. Click on the Config hypertext to open on your preferred editor. (e.g. C:\<Path-To-Project>\.vs\config\applicationhost.config)

Hope this helps.



回答3:

I wanted to add my version of a very similar answer because I still had to do some searching to get the expected end results. Although the original question just really wanted to know why the current config that was being used was not working and it was in fact explained in the accepted answer, it did not help someone like me coming into the question. I needed to know everything to do in order to achieve allowing parent paths when debugging. So here is my answer in detail...

How to configure the IIS debug server in Visual Studio 2015 to allow parent paths:

First you need to find the IIS Express tray icon.

Next you need to open the IIS config currently running for debugging by right clicking on that tray icon. You will then see the following context menu. You will need to click on "Show All Applications".

This will then show you the configurations of the IIS debug server you are running. There will also be the project you are working on listed in this list.

Click the projects name (in this case "Web") under the Site Name column. You will then see the Path of the project and the Config file being use to run the debug IIS server. You will then click on the Config path to open the applicationhost.config in your default text editor.

This will open up the config file you are using when debugging your project. You will need to scroll down until you find the <system.webServer> section. Then look for the <asp> section. In my case it was <asp scriptErrorSentToBrowser="true">.

Then you just need to edit the asp section to include enableParentPaths="True" as shown in the image below.

The just save the file and restart the debugging process. Note: I only had to hit F5 in the IE browser to see the change. I did not have to close the browser and restart the debug process over again.