How to get rid of 401.2 in asp.net mvc? - asp.net

I've read a lot of documentation on this error and it all seems to point to modifying applicationHost.config. I've made the modifications and mine looks like:
<system.webServer>
<asp />
<security>
<authentication>
<windowsAuthentication enabled="true" />
<anonymousAuthentication enabled="false" />
</authentication>
</security>
</system.webServer>
I've restarted the website but still get the same error.
I'm running IIS6. Any ideas what I'm doing wrong?

Related

How to allow LINK and UNLINK on IIS 10

I'm exploring HTTP verbs like LINK and UNLINK. There is a simple website on IIS 10 for this purpose but looks like it doesn't allow these methods by default. I added a couple of rules in Request Filtering for verbs and still getting 405 error.
UPD
web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<trace enabled="true" writeToDiagnosticsTrace="true" />
</system.web>
<system.webServer>
<security>
<requestFiltering>
<verbs>
<add verb="LINK" allowed="true" />
<add verb="UNLINK" allowed="true" />
</verbs>
</requestFiltering>
</security>
</system.webServer>
</configuration>

Anonymous authentication using generic asp.net handler (*.ashx)

I have an asp.net webforms application that has windows authentication enabled. I need to enable anonymous authentication on a folder “Test” in the website which contains images . I did that by adding
<location path="Test">
<system.webServer>
<security>
<authentication>
<anonymousAuthentication enabled="true"/>
</authentication>
</security>
</system.webServer>
Now any requests to images in Test folder is unauthenticated and everything works as expected until I introduced a generic handler for this folder which fetches files from the backend storage if the file is not found in the “Test” folder and boom it broke! Anonymous authentication doesn’t work anymore. Updated web.config file below -
<location path="Test">
<system.webServer>
<handlers>
<add verb="*" path="Test" requireAccess="None" name="Handler1" type="WebApplication1.Test.Handler1, Anonymous" />
</handlers>
<security>
<authentication>
<anonymousAuthentication enabled="true"/>
</authentication>
</security>
</system.webServer>
I inspected the request using fiddler and it returns HTTP/1.1 401 Unauthorized message if I have the handler section in config but if I remove the handler section from config everything just works fine and I can see the valid response in fiddler. Any insight into what could be wrong here?
Finally I was able to resolve it myself by modifying the location configuration as shown below by adding system.web to allow all users
<location path="Test">
<system.webServer>
<handlers>
<add verb="*" path="Test" requireAccess="None" name="Handler1" type="WebApplication1.Test.Handler1, Anonymous" />
</handlers>
<security>
<authentication>
<anonymousAuthentication enabled="true"/>
</authentication>
</security>
</system.webServer>
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>

IIS alwaysAllowedUrls not recognized

I wanted to add some IIS requestFiltering rules to my web application. I followed folling guides:
http://www.iis.net/configreference/system.webserver/security/requestfiltering/alwaysallowedurls
http://www.iis.net/configreference/system.webserver/security/requestfiltering/denyurlsequences
For example, I want to deny Url test but enable testallowed
So I made following configuration in my web.config:
<system.webServer>
<security>
<requestFiltering>
<denyUrlSequences>
<add sequence="test" />
</denyUrlSequences>
<alwaysAllowedUrls>
<add url="testallowed" />
</alwaysAllowedUrls>
</requestFiltering>
</security>
</system.webServer>
Wenn calling mypage/test, I get the IIS HTTP Error 404.5 Page, which is correct. But I get the same page when calling mypage/testallowed. And in my web.config, the Tag alwaysAllowedUrls is underlined and it says:
The element 'requestFiltering' has invalid child element 'alwaysAllowedUrls'. List of possible elements expected: 'fileExtensions, requestLimits, verbs, hiddenSegments, denyUrlSequences'.
this is the syntax as per the IIS documentation :
<system.webServer>
<security>
<requestFiltering>
<denyUrlSequences>
<add sequence="bad" />
<add sequence="sequence" />
</denyUrlSequences>
<alwaysAllowedUrls>
<add url="/bad_sequence.txt" />
</alwaysAllowedUrls>
</requestFiltering>
</security>
</system.webServer>
https://www.iis.net/configreference/system.webserver/security/requestfiltering/alwaysallowedurls?showTreeNavigation=true

Why do we have problems with the location tags in web.config under IIS7.5?

In IIS 7.0, having location tags in web.config works fine.
Example:
<configuration>
....
<location path="export">
<system.webServer>
<security>
<authentication>
<anonymousAuthentication enabled="false"/>
<windowsAuthentication enabled="false"/>
</authentication>
</security>
</system.webServer>
</location>
We recently installed Windows 7 on our machines and in IIS 7.5 all of these location tags do not work anymore.
Can you try <system.web> instead of http://msdn.microsoft.com/en-us/library/b6x6shw7.aspx

Can't add sessionState to web.config without Error 500.19

I'm in the process of creating a new web application using classic ASP. I've done this before and have 2 similar websites that have been running for over 2 years. My problem is that the ISP I'm using has me hosted on a system running Server 2008, IIS7, and I cannot rely on session state remaining constant. I use a session variable to pass validated usernames from page to page. I know I can re-write the application to use db storage as an alternative, but I hate to have to modify a working application.
In talking with the ISP they suggested adding a sessionState variable to my web.config file and use stateserver to pass the data to a file on their system (they provided the connection string, etc.). This seems fine, but whenever I add the sessionState line to the web.config the website gets a error 500.19 with an error code of 0x8007000d.
I've tried to add a line on my local PC to simply change the session timeout as a testing methodology, but I get the same error. I'm sure it's something obvious, but I've researched the general topic and it looks like it should work? The simple web.config code is below and any suggestions would be greatfully appreciated (I'm developing a flat spot on my forehead from hitting the desk).
Thanks,
Contents of web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<sessionState timeout="40" />
<defaultDocument enabled="true">
<files>
<clear />
<add value="index.aspx" />
<add value="index.asp" />
<add value="default.htm" />
<add value="default.html" />
</files>
</defaultDocument>
<security>
<authentication>
<basicAuthentication enabled="true" />
</authentication>
</security>
<httpErrors errorMode="Custom">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/OaOInternal/DefaultWebs/sedoCurrent/Error404.aspx" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
</configuration>
classic ASP sites don't use web.config files

Resources