In this guide, we will discuss how to resolve the common ASP.NET issue related to the Integrated Managed Pipeline Mode. If you have ever encountered an error message like the one below, this guide will help you understand and fix the problem.
The application is configured to issue secure cookies. These cookies require the browser to issue the request over SSL (https protocol). However, the current pipeline is not configured for this. To allow this, set the `System.webServer/security/requestFiltering/allowRestrictedChars` attribute in the `web.config` file to `true`.
Table of Contents
Understanding the Issue
The error is caused when your ASP.NET application is configured to run in Integrated Managed Pipeline Mode but encounters issues due to the way requests are processed. This problem usually occurs when using IIS 7 or later versions, which introduced the Integrated Managed Pipeline Mode for better performance and extensibility.
In Integrated Mode, the ASP.NET runtime and the IIS core work together to process requests. This can cause issues when certain settings or configurations are not aligned correctly. In this case, the application is configured to issue secure cookies, but the current pipeline is not configured to allow this.
Step-by-Step Solution
To resolve this issue, follow the steps below:
Open your web.config
file located in the root folder of your ASP.NET application.
Locate the <system.webServer>
section. If it does not exist, create one.
Within the <system.webServer>
section, find the <security>
and <requestFiltering>
elements. If they do not exist, create them as shown below:
<system.webServer>
...
<security>
<requestFiltering>
...
</requestFiltering>
</security>
...
</system.webServer>
- Add the
allowRestrictedChars
attribute within the<requestFiltering>
element and set its value totrue
:
<system.webServer>
...
<security>
<requestFiltering allowRestrictedChars="true">
...
</requestFiltering>
</security>
...
</system.webServer>
- Save the changes to your
web.config
file and restart your application.
The error should now be resolved, and your application should be able to issue secure cookies without any issues.
FAQ
1. What is the Integrated Managed Pipeline Mode?
Integrated Managed Pipeline Mode is an IIS feature introduced in version 7. It allows the ASP.NET runtime and IIS core to work together, providing better performance and extensibility over the Classic Mode, where ASP.NET and IIS run separately. Learn more about Integrated Managed Pipeline Mode.
2. How do I know if my application is running in Integrated Managed Pipeline Mode?
You can check your application pool settings in IIS Manager under the "Advanced Settings" option. Look for the "Managed Pipeline Mode" setting, which will either be set to "Integrated" or "Classic." Learn how to check the application pool settings
3. Can I switch my application from Integrated Managed Pipeline Mode to Classic Mode?
Yes, you can switch your application to Classic Mode if it is compatible with your application's requirements. However, using Integrated Managed Pipeline Mode is recommended for better performance and extensibility. Learn how to switch between pipeline modes
4. Will changing the allowRestrictedChars
attribute have any security implications?
Setting the allowRestrictedChars
attribute to true
allows the use of restricted characters in URLs. This can increase your application's vulnerability to potential security threats. It is essential to ensure proper input validation and sanitization to mitigate any risks. Learn more about request filtering and security
5. Can I apply this fix at the server level instead of the application level?
Yes, you can apply this fix at the server level by modifying the applicationHost.config
file located in the %windir%\system32\inetsrv\config
folder. You can add the same configuration settings as mentioned in the guide. However, be cautious when making changes at the server level, as it will affect all applications running on the server. Learn more about the applicationHost.config file