Problem with <httpErrors> in web.config

antic

Perch
I have a site on win34. When I add this section in web.config, I get an error:
Code:
  <system.webServer>
    <httpErrors>
       <remove statusCode="404" subStatusCode="-1" />
       <error statusCode="404" path="/index.shtml" responseMode="Redirect" />
    </httpErrors>
  </system.webServer>
Pages work normally, but when I try a non-existent page (to test the 404 redirect), the server responds with "The page cannot be displayed because an internal server error has occurred."

I don't have any error pages set up in HSphere.
Am I doing something wrong? Theoretically it should work, if win34 is IIS7.
 
Thanks Dipesh, will do. I'll also ask you to enable detailed error messages instead of IIS's unhelpful default messages. :)
 
I was told to set up 404 errors in HSphere, instead of in web/config.
I was also told to rename web.config before doing that.

Does that mean I can't use web.config at all, because of HSphere?
 
It can, but it is verrrrrrryyyy picky about syntax and settings. In reality hsphere is doing same edit just in applicationhost.config id guess you have a minor error here in config so it freaks out and doesnt work. This is not uncommon.
 
Did some testing, and found that the presence of <httpErrors> section in <system.webServer> will cause an error if a 404 or other http error is encountered. It seems to ignore the <customErrors> section in <system.web> altogether. But that's ok, HSphere is fine for that.

However, one can still define SMTP defaults and *squee* URL rewriting! In fact, if you set a 404 document in HSphere, the url rewrite rule in web.config supersedes it, if the missing page matches the rule. That's great, I'd prefer web.config to have the power. :)

Code:
  <system.net>
    <mailSettings>
      <smtp deliveryMethod="Network">
        <network
          host="mail.mydomain.com" 
          port="587"
          userName="[email protected]"
          password="password"
        />
      </smtp>
    </mailSettings>
  </system.net>

  <system.webServer>
    <rewrite>
      <rules>
        <rule name="friendly urls, everything is sent to default.aspx">
          <match url=".*" />
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          </conditions>
          <action type="Rewrite" url="default.aspx" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>

Tested both these things and they work well.
Very happy about the url rewriting!
 
Back
Top