3

Asp.Net contains a mechanism to specify the default document in a web.config:

<defaultDocument>
    <files>
        <remove value="default.aspx" />
        <remove value="Default.asp" />
        <remove value="index.html" />
        <remove value="Default.htm" />
        <remove value="index.htm" />
        <remove value="iisstart.htm" />
        <remove value="landing.aspx" />
        <remove value="views.aspx" />
        <remove value="index.aspx" />

        <add value="landing.aspx" />
        <add value="views.aspx" />
        <add value="index.aspx" />
    </files>
</defaultDocument>

Is there a mechanism to retrieve the document that will be used for a certain local path request?

Requests could be: /MySite/ (index.aspx), /MySite/Views/One (views.aspx), /MySite/Pages/PageOne (landing.aspx). Each directory contains a different "default document".

Aleksei Poliakov
  • 1,322
  • 1
  • 14
  • 27
Kees C. Bakker
  • 32,294
  • 27
  • 115
  • 203
  • Have you tried wrapping them in location tags? – Shawn Nov 13 '13 at 14:33
  • @Shawn I don't understand what that means. Can you elaborate? – Kees C. Bakker Nov 13 '13 at 14:34
  • Something like this: http://stackoverflow.com/questions/10045625/different-default-document-for-iis-sub-application I would assume you could just change the paths to /Mysite /MySite/Views/One, etc. – Shawn Nov 13 '13 at 14:35
  • No I'll need to find the file name to do some rewriting by my app. I can't rely on Asp.Net to get it right. That's why my code need to detect what default page Asp.Net should have used. – Kees C. Bakker Nov 13 '13 at 14:37
  • 1
    Request.PhysicalPath gives you the file (on filesystem) that asp.net is trying to load. But I guess you want to get the document name before there is any request. – Willem Nov 13 '13 at 15:28
  • 2
    Maybe [`VirtualPathProvider`](http://msdn.microsoft.com/en-us/library/system.web.hosting.virtualpathprovider(v=vs.110).aspx) is a good point to look at. – Saeed Neamati Nov 13 '13 at 16:36
  • If you are using MVC - check out [this question](http://stackoverflow.com/questions/2808075/asp-net-mvc-route-to-url) - it explains how to get from url like `/MySite/Views` to the `/MySite/Views/Index` by routes – Aleksei Poliakov Dec 24 '13 at 19:42
  • @DarkWalker, I'm using ASP.Net forms. – Kees C. Bakker Dec 24 '13 at 19:58
  • Try this link http://stackoverflow.com/questions/421778/asp-net-site-default-document-in-subfolder http://technet.microsoft.com/en-us/library/cc732107.aspx – Akhil Jan 23 '14 at 02:07

1 Answers1

0

Just add a Web.Config file inside each directory with the settings you want to override, in this case, with the defaultDocument settings

Nuno Agapito
  • 220
  • 3
  • 12