We are having开发者_StackOverflow中文版 a problem on our web server which is driving us mad!!
When we define defaultDocument in our web.config we always get the dreaded 403.14 Http error. The config is (inside system.webserver):
<defaultDocument enabled="true">
<files>
<clear/>
<add value="~/Forms_Mosaic/Our System.aspx"/>
</files>
</defaultDocument>
We are using IIS 7.0 and if we turn directory browsing on we can happily browse to the specified file. We have the folders that it reside in set to ANONYMOUS LOGON user credentials and can also access the page with a fully qualified url.
Can anyone suggest why we keep getting this error?
Thanks.
I came across a similar issue today and found that the tilde (~) and leading forward slash were causing the issue. For example, while the following doesn't seem to work:
<defaultDocument enabled="true">
<files>
<add value="~/test.htm" />
</files>
</defaultDocument>
specifying the file just as a plain-ole-relative URL worked fine, at least for me:
<defaultDocument enabled="true">
<files>
<add value="test.htm" />
</files>
</defaultDocument>
Note though that if your desired default document's in a subfolder relative to the application root (as seems to be the case for you) then when you browse to the subfolder you're going to get the same issue. For example, if you browse to http://example.com/Forms_Mosaic/ IIS'll be looking for a default document at http://example.com/Forms_Mosaic/Forms_Mosaic/Our%System.aspx which obviously won't exist.
Strikes me that a default.aspx in the root folder with a Server.Transfer or Response.Redirect might be a better solution in the specific case of the OP, rather than using a site-wide setting to handle what's really a folder-specific problem.
The value you specified is not a valid URL. Try:
<defaultDocument enabled="true">
<files>
<clear/>
<add value="~/Forms_Mosaic/Our%20System.aspx"/>
</files>
</defaultDocument>
You may also get this error if you are using urlMappings. In this case, the value will have to be the non-mapped value. So for the following situation, you will see the error if the value is page-b.aspx but not if it is page-a.aspx.
<urlMappings>
<add mappedURL="~/page-a.aspx" url="~/page-b.aspx" />
</urlMappings>
精彩评论