10

how can i make it that when i go to (for example) http://localhost:60288/ it does not show me a directory listing but rather opens the Index.aspx page? This works with http://localhost:60288/Index.aspx but i don't wish to have Index.aspx shown every time.

i also need links like http://localhost:60288/?a=1 to work like http://localhost:60288/Index.aspx?a=1 without the Index.aspx shown.

this used to work when i created a website project in visual studio, but now i'm using application project. how can I set this up?

i want / need this to work for all sub folders as well e.g. http://localhost:60288/SubFolder/ should work as if it was linked to http://localhost:60288/SubFolder/Index.aspx

thnx

edit still did not manage it

b0x0rz
  • 3,953
  • 8
  • 52
  • 82
  • There are specific issues in this respect with the development server - I can't find the references quickly or I'd add an answer. You need to test the behaviour in IIS. – Murph Nov 15 '09 at 11:11

5 Answers5

13

Cassini (the built-in webserver used by Visual Studio) doesn't allow you to configure the Default Document that's used if you don't specify a filename in your URL. The 'Set as Start Page' option isn't the same thing, as you've found, since that only affects which page is first opened when you run the project, and doesn't affect subsequent page-loads.

However, Cassini does have a list of Default Documents - it just isn't configurable, and the list only contains "default.aspx" and "default.htm". The only way you could achieve what you want in Cassini is to rename all your "index.aspx" files to "default.aspx".

Chris
  • 4,661
  • 1
  • 23
  • 25
  • thank you very much :) default.aspx is just as good for us as index.aspx so we switched. i actually suggested to use the default.aspx before ;) EXCELLENT! – b0x0rz Nov 18 '09 at 16:06
  • When I have a second_page.aspx open on the screen and i hit ISS it starts with that second page on the web page. It didn't really work for me. Any ideas? – Vaggelis Manousakis Feb 13 '20 at 18:19
9

The easiest way for me to do this was to use a mapping. Inside your Web.config, insert the following:

<configuration>                                                                  
    <system.web>                                                                 
        <compilation debug="true" targetFramework="4.0" />                       
        <urlMappings enabled="true">                                             
            <add url="~/" mappedUrl="~/index.aspx" />                
            <add url="~/default.aspx" mappedUrl="~/index.aspx" />                
        </urlMappings>                                                           
    </system.web>                                                                
</configuration>            
class
  • 8,621
  • 29
  • 30
  • Great answer man, so this solution works for both if I am using vs development server as well as Windows IIS am I right ? Also because other suggestions were using the defaultDocument under system.webserver but it did not work for development server for me. – user123456 Aug 04 '18 at 07:46
2

Go into the IIS manager (in control panel - administrative tools)

Right click - properties on the default website

Documents tab - ensure that 'enable default document' is ticked, and that index.aspx is in the list of default documents, up the top preferably.

Home directory tab - make sure you've got an application created (application name shouldn't be blank). Click the 'create' button if you need to.

asp.net tab - check that you've selected the correct version of the framework that you want.

Let me know how you go.

Chris
  • 39,719
  • 45
  • 189
  • 235
0

You can use IIS Manager to set the Default document(s) for your site/application.

Cassini (the development web server integrated in Visual Studio) doesn't support the possibility to change the default document.

And yes, you do need to be an administrator to configure IIS.

Joe
  • 122,218
  • 32
  • 205
  • 338
  • yeah. not sure how to do that and i did google it (perhaps my queries were wrong). another thing is i'm not using IIS (in the project properties) but rather the visual studio development server. – b0x0rz Nov 15 '09 at 10:22
  • if i try switching to IIS server in the project properties i get the error message that i need to run visual studio as administrator PLUS install some additional components (listed): internet information services, iis6 metabase and iis6 configuration compatibility, asp.net.!? – b0x0rz Nov 15 '09 at 10:24
0

You can remove or rename your index.aspx , so that it will show the directory listing when runs unless you set another page as start page.

For the second thing, u can use ASP.NET URL masking feature

Shyju
  • 214,206
  • 104
  • 411
  • 497
  • it already does show directory listing when accessing `http://localhost:60288/` and this is exactly what i do NOT want. i want to access `http://localhost:60288/` and have the `Index.aspx` page be started / shown. – b0x0rz Nov 15 '09 at 10:51